Numeric Array Sort | JavaScriptSource

Numeric Array Sort

Patrick Hunlock Mar 21, 2007


JavaScript's Array object only sorts alphabetically. That means if you pass it an array of numbers it will sort the array alphabetically (1,15,100,2,25,200) instead of numerically (1,2,15,25,100,200). This is easily fixed by adding a new method which will sort a numerical array very nicely.

Current Array: 5,9,12,18,56,1,10,42,30,7,97,53,33,35,27

Click to sort


Source Code

Paste this source code into the designated areas.


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response

(1 comment)

This Numeric Array Sort is very clever. An alternate approach which is very simple. One of the most usable scripts submitted for a long time.

D10n... Mar 24, 2007