https://github.com/hanford/double-sort
sort an array by two object parameters
https://github.com/hanford/double-sort
javascript npm-package sort sort-array-js
Last synced: 3 months ago
JSON representation
sort an array by two object parameters
- Host: GitHub
- URL: https://github.com/hanford/double-sort
- Owner: hanford
- Created: 2017-04-03T20:46:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-03T22:53:43.000Z (about 8 years ago)
- Last Synced: 2025-03-22T15:50:03.024Z (3 months ago)
- Topics: javascript, npm-package, sort, sort-array-js
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# double-sort
> Sort an array on two object properties
## Install
```
$ npm install --save double-sort
```## Usage
```js
const doubleSort = require('double-sort');// sort by two object properties
doubleSort([{pending: 1, type: 'DEL'}, {pending: 2, type: 'HOLD'}, {pending: 3, type: 'DEL'}, ...], 'type', 'pending');
//=> [{pending: 3, type: 'DEL'}, {pending: 1, type: 'DEL'}, {pending: 2, type: 'HOLD'}, ...]
```## API
### doubleSort(input, property1, property2)
Returns a new sorted array.
#### input
Type: `Array`
#### property1
Type: `string`
First parameter to be sorted on.
#### property2
Type: `string`
Second parameter to be sorted on. (property1 will always be respected first.)
## License
MIT © [Jack Hanford](https://jackhanford.com)