3 ms·
Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this
by delinka 8y ago
Is it just me, or do none of them sort this array correctly?
["zebra","apple","banana","5","bapple","banana","banana"]
Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR
1 - http://stackoverflow.com/questions/3730510/#3730579 http://stackoverflow.com/questions/3730510/#3730579
- keerthiko 8y agothe website doesn't verify the accuracy of sort output. it just gives you the first SO answer that a) has a code snippet b) which is error-free c) and has a function that can be extracted and run ...for your input format, and returns the output of passing your input code into it. It's true to the xkcd mission, which is just to find SO answers until it returns something, not to actually confirm it was sorted correctly.
- delinka 8y agoThe alt-text on the linked comic says "...until the list is sorted." Ergo, one must verify that it is sorted before knowing whether to execute the next code snippet.
- hirsin 8y agoThat conversation about for..in - any JS experts that can say whether modules or other new advances will help with this? Not being able to use the standard functions on primitives because random other code messes with them sounds like pogo sticking in a minefield.
- tomjakubowski 8y agofor (let x of xs) in more recent versions of JS is how you iterate an array without facing that prototype pollution problem. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- hirsin 8y agoGood to know, thanks!
- kenjackson 8y agoMaybe they just have a different definition of "correctly" sorted.