The fix itself is small, like a one-line comparator flip, but I spent more time than I should've re-reading the surrounding code to make sure I wasn't missing some intentional design choice.
First, locate the sorting logic and identify the comparator or key function used. Then, analyze the current ordering direction and modify it to reverse the priority order, ensuring higher priority values come first. Finally, verify the fix with test cases covering edge cases like equal priorities and empty lists.
Pro tip: When reversing a sort, consider whether the priority values are numeric or categorical; for numeric, simply negate the comparator or use reverse=True, but for categorical, you may need to define a custom order. Also, check if the sort is stable and whether reversing affects secondary criteria.
Search the codebase for sorting functions, comparators, or key functions related to projects and priority. Identify the exact line or block responsible for ordering.
Determine how the current sort works: is it ascending by priority value? What data type is priority? Are there any secondary sort keys?
Modify the sort to process higher priorities first. For numeric priorities, negate the comparator or use a descending sort. For custom orders, adjust the key function accordingly.
Run existing tests and add new ones to verify that projects are now ordered from highest to lowest priority. Include edge cases such as equal priorities and empty input.
Check if the sort is used elsewhere and whether reversing it impacts other functionality. Ensure the change is localized and doesn't break dependent code.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.