You have a list of students with their grades:
- Johnson C
- Harris A
- Miller C
- Smith B
- Taylor A
The list is sorted alphabetically. Now you need to sort it by grades (A-B-C), but you want to preserve the alphabetic order as well. So that among students with A, Harris comes first, then Taylor, and so on. What kind of algorithm do you need for this task?