I\'m using Javascript sort (with Underscore.js):
sort
_.sortBy([\"Bob\", \"Mary\", \"Alice\"], function (name) {return name}) > [\"Alice\", \"Bob\", \
I would just do what Underscore does under the hood: use the Array#sort method.
["Bob", "Mary", "Alice"].sort(function (a, b) { if (a < b) return 1; if (b < a) return -1; return 0; });
Or if you don't want the original array modified, clone it first:
_.clone(["Bob", "Mary", "Alice"]).sort(...)