Skip to content

Instantly share code, notes, and snippets.

@petrosalema
Created July 13, 2011 21:12
Show Gist options
  • Save petrosalema/1081349 to your computer and use it in GitHub Desktop.
Save petrosalema/1081349 to your computer and use it in GitHub Desktop.
What is the problem with this valid JavaScript?
var alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
var order = "desc";
alphabet.sort(function (a, b) {
return
a == b
? 0
: (order == "desc" ? -1 : 1)
* (a < b ? -1 : 1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment