Maybe I'm the only one who missed the memo, but in case anyone else is wondering what a hash is doing in JS:<p>"When writing (in text, not in JavaScript) about properties on specific prototypes, you may use the JavaScript notation, foo.prototype.bar. However, this shorter (non-JavaScript) notation is often used instead: foo#bar. Basically, the hash (#) stands for .prototype. — fancy huh?"<p><a href="http://mathiasbynens.be/notes/javascript-prototype-notation" rel="nofollow">http://mathiasbynens.be/notes/javascript-prototype-notation</a>
This is fixed in Python:<p>The sort() method takes optional arguments for controlling the comparisons.<p>"key" specifies a function of one argument that is used to extract a comparison key from each list element.<p>In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function. This is because cmp is called multiple times for each list element while key and reverse touch each element only once.<p><a href="http://docs.python.org/library/stdtypes.html" rel="nofollow">http://docs.python.org/library/stdtypes.html</a>
For a moment, I thought there was actually something new about sorting. That turned out not to be the case, of course.<p>I understand the importance of linkbait titles, but specifying the context (e.g. "we're doing it wrong in JavaScript") would save people time without weakening the impact on those who might be interested in the article (JavaScript developers).
This is a very cool visualiser that was posted on HN before if anyone feels like playing: <a href="http://visualsort.appspot.com/" rel="nofollow">http://visualsort.appspot.com/</a>
javascript sorting: having expected a sorting somewhat similar to python and being very... surprised that javascript essentially sorts everything but primitive types by comparing their String counterparts, I decided to implement a more sensible compare function, similar to e.g. python:<p><a href="https://gist.github.com/2772234" rel="nofollow">https://gist.github.com/2772234</a><p>I am currently using this in server only environments, so there is no comparison for DOM elements.