Stable Sorting in JavaScript…

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:

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.