1.0.4 • Published 3 years ago

copy-sort-polyfill v1.0.4

Weekly downloads
43
License
ISC
Repository
-
Last release
3 years ago

copy-sort-polyfill

Support Array.sort without mutating original array

Getting started

npm install copy-sort-polyfill

At the top level your application, import the polyfill.

require("copy-sort-polyfill")

How it works

To return a sorted array without mutating the original array, pass in the 2nd argument

const arr = [1, 4, 3]
const sorted = arr.sort(function (a, b) {
  return a - b
}, true)
console.log(arr)    // [1, 4, 3]
console.log(sorted) // [1, 3, 4]

Without adding the 2nd argument, the sort function will work as per native Array.sort

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.1

3 years ago