An open API service indexing awesome lists of open source software.

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

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
```