https://github.com/codewell/sort-object-array
Sort an array with objects in javascript
https://github.com/codewell/sort-object-array
Last synced: about 1 year ago
JSON representation
Sort an array with objects in javascript
- Host: GitHub
- URL: https://github.com/codewell/sort-object-array
- Owner: codewell
- License: mit
- Created: 2019-09-24T06:50:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:10:23.000Z (over 3 years ago)
- Last Synced: 2025-05-22T09:27:21.413Z (about 1 year ago)
- Language: JavaScript
- Size: 423 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @codewell/sort-object-array
Sort an array with objects in JavaScript based on keys
## Installation
```
npm install @codewell/sort-object-array
```
## Basic usage
```JavaScript
import sortObjectArray from '@codewell/sort-object-array';
const arr = [{age: 1}, {age: 3}, {age: 2}];
const sortedArr = sortObjectArray(arr, 'age');
const sortedArr2 = sortObjectArray(arr, 'age', true); // Reverse order
```