To prevent any frustration, it's recommend to read the full documentation before start using js_natsort.
During the work on my current project, I was looking for a possibility to sort arrays natural.
Because of some special cases, Javascript's sort() method was incomplete for my needs.
Js_natsort is able to sort integer, string (also string with numbers included) and mixed arrays.
It's up to you, how much characters will be compared, but note that huge arrays and lots of chars will slow down the script.
js_natsort - JavaScript natural sort
Copyright (C) 2007 Ingo Volkmann
Visit my site and get in contact with me at godiv.deThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
The installation is very simple.
Copy the js_natsort.js file to your webserver.
Put <script type="text/javascript" language="javascript" src="js_natsort.js"></script> between the <head></head> tags of your page.
Don't forget to adjust the 'src' attribute if the js_natsort.js file is not located in the same directory as your page.
By modify the variable js_natsortLimit you define the number of compared characters.
The variable js_natsortType defines the type of the natsort function - valid values are 1 or 2.
all global vars and functions are prefixed by js_natsort or js_natcasesort to prevent any collisions with your own scripts
js_natsort (1) - the lower cases will be sorted directly after their upper ones (Aa - Ab - aa - Ba)
js_natsort (2) - the lower cases will be sorted after the last upper case (Aa - Ab - Ba - aa)
js_natcasesort - the lower cases will be sortet between the upper ones (Aa - aa - Ab - Ba)array.sort(js_natsort);
array.sort(js_natcasesort);
- nothing at present