Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

natural-sort

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

natural-sort

Sorting with support for numbers, dates, unicode and more.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
increased by8.63%
Maintainers
1
Weekly downloads
 
Created
Source

David – status of dependencies
Code style: airbnb

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

  1. Download the script. You can use npm or bower:
npm install natural-sort
bower install natural-sort
  1. 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.

 

License

MIT © Studio B12 GmbH

FAQs

Package last updated on 08 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc