Quick answer: GameMaker ds_priority structure returning the wrong end first? Picking find_max+delete_max vs find_min+delete_min determines which end is the “top”.
An A* pathfinder uses a priority queue. Picking find_max instead of find_min returns farthest-first, breaking the algorithm.
Priority Direction
ds_priority is a heap with both ends accessible. Use a consistent pair: find/delete min OR find/delete max. Mixing leads to bugs.
Common Patterns
A* / Dijkstra: lowest f-score first, use find_min. Cooldown queue: earliest-time first, find_min. Highest-priority alert: find_max.
Custom Comparators
If you need custom ordering (multi-key tiebreaks), assign composite numeric priorities: scaled high-bits = primary key, low-bits = secondary. Keeps ds_priority usable.
Use struct + sort
For complex comparators, an array of structs with a sort function may be cleaner than ds_priority — arrays are GC-safe, ds_priority needs explicit destroy.
Verifying
Priority queue returns items in expected order. Algorithms (pathfinding, scheduling) produce correct results.
“Pick min or max per ds_priority — stay consistent across find/delete.”
For new code, prefer arrays + struct + sort — you get the same priority semantics with GC and easier debugging.