4 ms·
This was inspired by the alt-text from last week's "Ineffective Sorts" xkcd (http://xkcd.com/1185/ http://xkcd.com/1185/). It tries to sort a list or JSON by f
by gkoberger 14y ago
This was inspired by the alt-text from last week's "Ineffective Sorts" xkcd (http://xkcd.com/1185/ http://xkcd.com/1185/).
It tries to sort a list or JSON by fetching code from StackOverflow until it properly sorts the input.
- fwenzel 14y agoDo you test the result, or just hope if it runs, it actually worked?
- jstanley 14y agoI found one that returned the wrong result, so it seems to just assume it works as long as it runs.
- gkoberger 14y agoIt doesn't test for two reasons: 1) I thought it would defeat the purpose 2) "Sort" is very arbitrary. Do you want to sort by key or value? Is "1000" bigger or smaller than "2"? etc
- fwenzel 14y agoFair; also, it's called an 'ineffective' sort, and if you tested it, it'd become effective (not efficient, of course). So, good point!
- simcop2387 14y agoYou could probably test it by taking multiple sorts from SO and then comparing results. the moment you get two that agree, you have a winner!
- crusso 14y agoNicely done. I enjoyed looking at the code. For those of you who want to jump straight to the meat of it, go here: https://github.com/gkoberger/stacksort/blob/master/js/script.js https://github.com/gkoberger/stacksort/blob/master/js/script... Search down for "run_snippet_go"
- unfletch 14y agoFYI, you can link to a specific line on GitHub by appending #L<line no.> to the URL. In this case: https://github.com/gkoberger/stacksort/blob/master/js/script.js#L138 https://github.com/gkoberger/stacksort/blob/master/js/script... GitHub even adds the anchor for you if you click on the line number in the gutter. (shift-click to select a range of lines.)