In many greedy problems, the core idea is figuring out what to sort by. Common choices:
End time: : activity selection, interval scheduling
Start time: : merging intervals
Ratio: : fractional knapsack (value/weight)
Absolute value: : one quantity ascending, another descending
Deadline: : job scheduling Wrong sort order = wrong answer. Right sort order = optimal greedy solution. How do you find the right order? Try small examples. If sorting by X gives wrong answers, try Y.