multi-sort
v2.0.0
Published
[![Build Status](https://travis-ci.org/xiCO2k/multi-sort.svg?branch=master)](https://travis-ci.org/xiCO2k/multi-sort) [![npm downloads](https://img.shields.io/npm/dt/multi-sort.svg)](https://npmcharts.com/compare/multi-sort?minimal=true)
Downloads
1,772
Readme
multi-sort
Multidimensional Sort Helper
Installation
With npm:
$ npm i multi-sort
or with yarn:
$ yarn add multi-sort
Usage
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'
});