News for hackers. Stuff that matters.
Re:Show HN: XKCD-inspired StackSort by cwlb on Monday March 18, 2013 @02:35PM (#5396209)
has nobody else noticed that the default list always sorts with the same algorithm? http://stackoverflow.com/questions/14761032/infinite-recursi...
Re:Show HN: XKCD-inspired StackSort by thedufer on Monday March 18, 2013 @02:48PM (#5396306)
That's because it always tried answers in the same order. If you tell it to keep going, it'll succesfully sort with http://stackoverflow.com/questions/4833651/javascript-array-... and http://stackoverflow.com/questions/12137690/javascript-sort-... as well.
Re:Show HN: XKCD-inspired StackSort by anonymous on Monday March 18, 2013 @04:22PM (#5396865)
Those two don't work in the general case.

The first only leaves the unique members of the list, so you get a sorted set. The second sorts lexicographically, because javascript's .sort() method on arrays sorts lexicographically. This means that if you have a list of numbers like [1, 2, 10], it will get sorted as [1, 10, 2]. Unless you pass your own comparator in.

What this page really demonstrates is that there is precisely one answer on stackoverflow containing a complete generic sort function in javascript (quicksort in fact).

Re:Show HN: XKCD-inspired StackSort by thedufer on Tuesday March 19, 2013 @03:13AM (#5399397)
Sorry; I should have specified that I only used the example input.
Re:Show HN: XKCD-inspired StackSort by gkoberger on Monday March 18, 2013 @02:55PM (#5396340)
Well, yeah... it's an algorithm. Hit "keep trying" (big yellow button) to find more results.

Or, fork it and play with the StackOverflow queries.

Re:Show HN: XKCD-inspired StackSort by fwenzel on Monday March 18, 2013 @05:23PM (#5397217)
Yeah sounds like shuffling the result set before running might add a bit more spice to this.