Created
June 19, 2013 18:09
-
-
Save leeoniya/5816476 to your computer and use it in GitHub Desktop.
test if js engine's Array#sort implementation is stable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test if js engine's Array#sort implementation is stable | |
var str = "abcdefghijklmnopqrstuvwxyz"; | |
str.split("").sort(function(a,b) { | |
return ~~(str.indexOf(b)/2.3) - ~~(str.indexOf(a)/2.3); | |
}).join("") == "xyzvwtursopqmnklhijfgdeabc"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment