1.0.4 • Published 4 years ago
@drcyph3r/dynamic-sort v1.0.4
Dynamic Sort
Fast and easy way to sort an array of objects based on a property with typescript support.
Installation
npm i @drcyph3r/dynamic-sort
yarn add @drcyph3r/dynamic-sort
Usage
import dynamicsort from '@drcyph3r/dynamic-sort'
let fruits = [
{
id: 1,
name: 'Apple'
},
{
id: 2,
name: 'Orange'
}
]
// sort the fruits array by id in ascending order
const sortedArr = fruits.sort(dynamicsort('id', 'asc'))
Props
Prop | Value |
---|---|
property | key of a json object |
order | asc , desc |
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.