From: Jan Schneider Date: Mon, 22 Nov 2010 18:20:09 +0000 (+0100) Subject: Add Array.numericSort(). X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b00006482a3eb45f5b1ef9521a69cf5945498a77;p=horde.git Add Array.numericSort(). --- 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); + }); +}