Numeric Array Sort

By Patrick Hunlock on 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


  • Created by: Patrick Hunlock
  • Web Site:
  • Posted: March 21, 2007

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