Created
July 30, 2013 01:57
-
-
Save shuhei/6109577 to your computer and use it in GitHub Desktop.
An example that shows Array.prototype.sort sorts strings in unicode order.
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
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