orderby-shiv
v1.0.1
Published
Sort/order arrays with orderBy.
Downloads
1
Readme
orderby-shiv
Order an array of objects by given key.
orderBy(array
, key
[, shouldDecend
])
Order array
by key
, and returns the result array.
array
: the array of objects to be orderd.key
: target key.shouldDecend
: [optional] Default: false. Iftrue
, the result will be in decending order.
Example
// In Node.js
var orderBy = require('orderby-shiv');
var ordered = orderBy(targetArray, 'id');
// In browser. Include `orderBy` through <script> tag, then:
var ordered = orderBy(targetArray, 'id'); // `orderBy` is attached to `window`.
License
MIT