Skip to content

Instantly share code, notes, and snippets.

@julienetie
Created March 24, 2015 21:34
Show Gist options
  • Save julienetie/54ba107c5b082dbf6abc to your computer and use it in GitHub Desktop.
Save julienetie/54ba107c5b082dbf6abc to your computer and use it in GitHub Desktop.
Sort Numerically
// Sort Numerically
Array.prototype.sortNumerically = function (direction) {
var _this = this;
function comparator(a, b) {
return direction < 0 ? b - a : a - b;
}
return _this.sort(comparator);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment