From b00006482a3eb45f5b1ef9521a69cf5945498a77 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 22 Nov 2010 19:20:09 +0100 Subject: [PATCH] Add Array.numericSort(). --- horde/js/horde-jquery.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/horde/js/horde-jquery.js b/horde/js/horde-jquery.js index 324fc2d94..b74a9feb3 100644 --- a/horde/js/horde-jquery.js +++ b/horde/js/horde-jquery.js @@ -76,4 +76,13 @@ Number.prototype.toPaddedString = function(len,pad) return str; }; -String.prototype.toPaddedString = Number.prototype.toPaddedString; \ No newline at end of file +String.prototype.toPaddedString = Number.prototype.toPaddedString; + +Array.prototype.numericSort = function() +{ + return $.map(this, function(n) { + return new Number(n); + }).sort(function(a, b) { + return (a > b) ? 1 : ((a < b) ? -1 : 0); + }); +} -- 2.11.0