fast-array-sort
v0.1.3
Published
[![Build Status](https://travis-ci.org/noasax/fast-array-sort.svg?branch=master)](https://travis-ci.org/noasax/fast-array-sort) [![Coverage Status](https://coveralls.io/repos/github/noasax/fast-array-sort/badge.svg?branch=master)](https://coveralls.io/git
Downloads
46
Readme
fast-array-sort
Installation
npm install fast-array-sort
Params
sort(array, comparator);
array
: The array to sortcomparator
: Function to use for sorting
Usage
const sort = require("fast-array-sort");
sort([4, 2, 5, 1, 3]);
// [ 1, 2, 3, 4, 5 ]
const arr = [
{ order: 1, name: "apple" },
{ order: 5, name: "banana" },
{ order: 4, name: "candy" },
{ order: 2, name: "dollar" },
{ order: 3, name: "emit" },
];
sort(arr, (l, r) => l.order < r.order);
/*
[
{ order: 1, name: "apple" },
{ order: 2, name: "dollar" },
{ order: 3, name: "emit" },
{ order: 4, name: "candy" },
{ order: 5, name: "banana" },
]
*/