I saw this article via a Stack Overflow answer. It’s a method for producing a stable sort order from an unstable sorting algorithm. The geek inside me meant I had to share…
The basic premise is that if you store the pre-sort positions, then in the sorting algorithm if you find two elements are equal, you use the original position to determine which to show first. Pretty clever yet simple, which is the kind of coding I like.