├── LICENSE ├── README.md ├── index.html ├── naturalSort.js ├── speed-tests.html └── unit-tests.html /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2008-2016 Jim Palmer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [Demo - Run QUnit test suite](http://overset.github.io/javascript-natural-sort/unit-tests.html) 3 | 4 | ### Simple numerics 5 | 6 | ```javascript 7 | >>> ['10',9,2,'1','4'].sort(naturalSort) 8 | ['1',2,'4',9,'10'] 9 | ``` 10 | 11 | ### Floats 12 | 13 | ```javascript 14 | >>> ['10.0401',10.022,10.042,'10.021999'].sort(naturalSort) 15 | ['10.021999',10.022,'10.0401',10.042] 16 | ``` 17 | 18 | ### Float & decimal notation 19 | 20 | ```javascript 21 | >>> ['10.04f','10.039F','10.038d','10.037D'].sort(naturalSort) 22 | ['10.037D','10.038d','10.039F','10.04f'] 23 | ``` 24 | 25 | ### Scientific notation 26 | 27 | ```javascript 28 | >>> ['1.528535047e5','1.528535047e7','1.528535047e3'].sort(naturalSort) 29 | ['1.528535047e3','1.528535047e5','1.528535047e7'] 30 | ``` 31 | 32 | ### IP addresses 33 | 34 | ```javascript 35 | >>> ['192.168.0.100','192.168.0.1','192.168.1.1'].sort(naturalSort) 36 | ['192.168.0.1','192.168.0.100','192.168.1.1'] 37 | ``` 38 | 39 | ### Filenames 40 | 41 | ```javascript 42 | >>> ['car.mov','01alpha.sgi','001alpha.sgi','my.string_41299.tif'].sort(naturalSort) 43 | ['001alpha.sgi','01alpha.sgi','car.mov','my.string_41299.tif' 44 | ``` 45 | 46 | ### Dates 47 | 48 | ```javascript 49 | >>> ['10/12/2008','10/11/2008','10/11/2007','10/12/2007'].sort(naturalSort) 50 | ['10/11/2007', '10/12/2007', '10/11/2008', '10/12/2008'] 51 | ``` 52 | 53 | ### Money 54 | 55 | ```javascript 56 | >>> ['$10002.00','$10001.02','$10001.01'].sort(naturalSort) 57 | ['$10001.01','$10001.02','$10002.00'] 58 | ``` 59 | 60 | ### Movie Titles 61 | 62 | ```javascript 63 | >>> ['1 Title - The Big Lebowski','1 Title - Gattaca','1 Title - Last Picture Show'].sort(naturalSort) 64 | ['1 Title - Gattaca','1 Title - Last Picture Show','1 Title - The Big Lebowski'] 65 | ``` 66 | 67 | ### By default - case-sensitive sorting 68 | 69 | ```javascript 70 | >>> ['a', 'B'].sort(naturalSort); 71 | ['B', 'a'] 72 | ``` 73 | 74 | ### To enable case-insensitive sorting 75 | ```javascript 76 | >>> naturalSort.insensitive = true; 77 | >>> ['a', 'B'].sort(naturalSort); 78 | ['a', 'B'] 79 | ``` 80 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |MIT
61 | 62 | 63 | 64 |Jim Palmer (jimpalmer@gmail.com)
Jim Palmer (jimpalmer@gmail.com)
75 | You can download this project in either 76 | zip or 77 | tar formats. 78 |
79 |You can also clone the project with Git 80 | by running: 81 |
$ git clone git://github.com/overset/javascript-natural-sort82 | 83 | 84 | 87 | 88 |