Package Exports
- natural-sort
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (natural-sort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
natural-sort.js
Sorting with support for numbers, dates, unicode and more.
Default features
- Numbers are handled properly (“2” is before “10”)
- Dates are detected and sorted as well
- Empty strings are after “z”
Usage
['10. tenth', 'odd', 1, '', '2. second'].sort(naturalSort())
// [1, '2. second', '10. tenth', 'odd', '']
[3, 4, 1, 5, 2].sort(naturalSort({direction: 'desc'}))
// [5, 4, 3, 2, 1]
['a', 'B'].sort(naturalSort())
// ['a', 'B']
['a', 'B'].sort(naturalSort({caseSensitive: true}))
// ['B', 'a']
Installation
- Download the script. You can use npm or bower:
npm install natural-sort
bower install natural-sort
- Include the script before yours:
<script src="/bower_components/natural-sort/dist/natural-sort.js"></script>
Credits
The original version of this algorithm was published by Jim Palmer in this blog post.