1. @isaacs/string-locale-compare
Compare strings with Intl.Collator if available, falling back to String.localeCompare otherwise
@isaacs/string-locale-compare
Package: @isaacs/string-locale-compare
Created by: isaacs
Last modified: Tue, 05 Apr 2022 21:11:22 GMT
Version: 1.1.0
License: ISC
Downloads: 7,787,965
Repository: https://github.com/isaacs/string-locale-compare

Install

npm install @isaacs/string-locale-compare
yarn add @isaacs/string-locale-compare

@isaacs/string-locale-compare

Compare strings with Intl.Collator if available, falling back to
String.localeCompare otherwise.

This also forces the use of a specific locale, to avoid using the system
locale, which is non-deterministic.

USAGE

 const stringLocaleCompare = require('@isaacs/string-locale-compare')

myArrayOfStrings.sort(stringLocaleCompare('en'))

// can also pass extra options
myArrayOfNumericStrings.sort(stringLocaleCompare('en', { numeric: true }))

API

stringLocaleCompare(locale, [options])

Locale is required, must be a valid locale string.

Options is optional. The following options are supported:

  • sensitivity
  • numeric
  • ignorePunctuation
  • caseFirst

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin