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

javascript-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

javascript-natural-sort

Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license

  • 0.7.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-10.63%
Maintainers
1
Weekly downloads
 
Created

What is javascript-natural-sort?

The javascript-natural-sort npm package provides a natural sorting algorithm for JavaScript. It allows you to sort strings in a way that is intuitive to humans, such as sorting 'item2' before 'item10'. This is particularly useful for sorting lists of filenames, version numbers, or any other strings that contain numbers.

What are javascript-natural-sort's main functionalities?

Basic Natural Sort

This feature allows you to sort an array of strings in a natural order. The code sample demonstrates sorting a list of items where the numerical part of the strings is taken into account.

const naturalSort = require('javascript-natural-sort');
const items = ['item10', 'item2', 'item1'];
items.sort(naturalSort);
console.log(items); // Output: ['item1', 'item2', 'item10']

Case Insensitive Sort

This feature allows you to perform a case-insensitive natural sort. The code sample shows how the sorting algorithm treats 'Item10' and 'item10' as equivalent.

const naturalSort = require('javascript-natural-sort');
const items = ['Item10', 'item2', 'item1'];
items.sort(naturalSort);
console.log(items); // Output: ['item1', 'item2', 'Item10']

Locale Aware Sort

This feature allows you to sort strings in a locale-aware manner. The code sample demonstrates sorting a list of strings with special characters.

const naturalSort = require('javascript-natural-sort');
const items = ['ä', 'a', 'z'];
items.sort(naturalSort);
console.log(items); // Output: ['a', 'ä', 'z']

Other packages similar to javascript-natural-sort

Keywords

FAQs

Package last updated on 02 Jan 2014

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