multi-sort
v2.0.0
Published
[](https://travis-ci.org/xiCO2k/multi-sort) [](https://npmcharts.com/compare/multi-sort?minimal=true)
Downloads
758
Readme
multi-sort
Multidimensional Sort Helper
Installation
With npm:
$ npm i multi-sortor with yarn:
$ yarn add multi-sortUsage
import MultiSort from 'multi-sort';
let arr = [
{ first_name: 'John', last_name: 'Doe' },
{ first_name: 'Anthony', last_name: 'Zipher' },
{ first_name: 'Anthony', last_name: 'Carlos' }
];
let sortedByFirstName = MultiSort(arr, 'first_name', 'ASC');
/* Sort by multi params */
let sortedByFirstAndLast = MultiSort(arr, ['first_name', 'last_name'], ['ASC', 'DESC']);
/* or */
let sortedByFirstAndLast = MultiSort(arr, {
first_name: 'ASC',
last_name: 'DESC'
});
