The easiest way is to sort by the secondary criteria, then sort again by the primary criteria using a stable sort algorithm. The order of the secondary criteria will stay the same with a stable algorithm.
tux4life commented: The most useful post in this thread :) +12
tux4life commented: You clarified my doubt :) +12
jephthah commented: Bork Bork Bork +12
Ancient Dragon commented: Good point :) +36
Tom Gunn 1,164 Practically a Master Poster
Hiroshe commented: Lots of help. Thanks +2
jephthah commented: taking back some points for being completely obtuse. -2
Tom Gunn 1,164 Practically a Master Poster
Tom Gunn 1,164 Practically a Master Poster
WaltP commented: We don't fix people's problems for them. We HELP them fix it themselves -4
Tom Gunn 1,164 Practically a Master Poster
Nick Evan commented: Solid advice IMO +19
Ancient Dragon commented: great explanation :) +36
tux4life commented: Excellent! +10
siddhant3s commented: Well explained +14
StuXYZ commented: Good post +5
Azurea commented: Awesome explanation! Thanks! +2