01 · Question
Use the language's built-in sort for each task:
- Sort strings in descending lexicographic order, ignoring case.
- Sort intervals by their end value.
- Sort cards by value, breaking ties with
clubs < hearts < spades < diamonds. - Sort cards in new-deck order:
hearts < clubs < diamonds < spades, then by value.
02 · Analysis
Describe the ordering key before writing syntax:
- Transform case when comparison should ignore it.
- Select the exact field that defines the order.
- Use a numeric rank map for categories with a custom order.
- Use multiple key fields to make tie-breakers explicit.
The built-in comparison sort takes comparisons. Include any non-constant key or comparison work in the final complexity.
03 · Solution