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.
Here’s the link to the article: http://blog.vjeux.com/2010/javascript/javascript-sorting-table.html
For those of you wondering why on Earth I’m looking at stable sorting algorithms in JavaScript, I suggest you keep an eye on my blog through next week, or come to my MarkLogic World lightning talk on my MLDB JavaScript API for MarkLogic.