Skip to content

Instantly share code, notes, and snippets.

@shuhei
Created July 30, 2013 01:57
Show Gist options
  • Save shuhei/6109577 to your computer and use it in GitHub Desktop.
Save shuhei/6109577 to your computer and use it in GitHub Desktop.
An example that shows Array.prototype.sort sorts strings in unicode order.
var sorted = ["山田", "佐藤", "鈴木", "石田"].sort().map(function (name) {
var code = name.split('').map(function (letter) {
return letter.charCodeAt(0);
}).join(' ');
return name + ' -> ' + code;
});
console.log(sorted);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment