by overset

Sort things "naturally" in Javascript

130 Stars 55 Forks Last release: Not found MIT License 54 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Demo - Run QUnit test suite

Simple numerics

>>> ['10',9,2,'1','4'].sort(naturalSort)


>>> ['10.0401',10.022,10.042,'10.021999'].sort(naturalSort)

Float & decimal notation

>>> ['10.04f','10.039F','10.038d','10.037D'].sort(naturalSort)

Scientific notation

>>> ['1.528535047e5','1.528535047e7','1.528535047e3'].sort(naturalSort)

IP addresses

>>> ['','',''].sort(naturalSort)


>>> ['','01alpha.sgi','001alpha.sgi','my.string_41299.tif'].sort(naturalSort)


>>> ['10/12/2008','10/11/2008','10/11/2007','10/12/2007'].sort(naturalSort)
['10/11/2007', '10/12/2007', '10/11/2008', '10/12/2008']


>>> ['$10002.00','$10001.02','$10001.01'].sort(naturalSort)

Movie Titles

>>> ['1 Title - The Big Lebowski','1 Title - Gattaca','1 Title - Last Picture Show'].sort(naturalSort)
['1 Title - Gattaca','1 Title - Last Picture Show','1 Title - The Big Lebowski']

By default - case-sensitive sorting

>>> ['a', 'B'].sort(naturalSort);
['B', 'a']

To enable case-insensitive sorting

>>> naturalSort.insensitive = true;
>>> ['a', 'B'].sort(naturalSort);
['a', 'B']

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.