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

@discoveryjs/natural-compare

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discoveryjs/natural-compare

Compare strings in a natural order

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
107K
decreased by-20.9%
Maintainers
3
Weekly downloads
 
Created
Source

NPM version Build Status Coverage Status

@discoveryjs/natural-compare

Compare strings in a natural order

Install

npm install @discoveryjs/natural-compare

Usage

import { naturalCompare } from '@discoveryjs/natural-compare';

[
    'file10.js',
    'file1.js',
    'file2.js',
    'file12.js',
    'file9.js'
].sort(naturalCompare);
// file1.js
// file2.js
// file9.js
// file10.js
// file12.js

// standart sorting
[
    'file10.js',
    'file1.js',
    'file2.js',
    'file12.js',
    'file9.js'
].sort();
// file1.js
// file10.js
// file12.js
// file2.js
// file9.js

In browser:

    <!-- ESM -->
    <script type="module">
        import { natualCompare } from "@discoveryjs/natural-compare/dist/natural-compare.esm.js";

        array.sort(naturalCompare);
    </script>

    <!-- Old way -->
    <script src="@discoveryjs/natural-compare/dist/natural-compare.js"></script>
    <script>
        array.sort(naturalCompare);
    </script>

License

MIT

Keywords

FAQs

Package last updated on 16 Sep 2022

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