Out of the box JavaScript Array.prototype.sort method uses simple yet effective approach — it converts every item to Unicode string and orders them by comparing respective code point values. That explains, why [1, 2, 10].sort() produces [1, 10, 2], instead of more logical [1, 2, 10]. If you want more, e.g. sort in descending order or by object property name, Array.prototype.sort accepts custom comparer function that allows you to implement your own sorting logic.