Syntax suggestion
mesqueeb opened this issue · 0 comments
mesqueeb commented
I thought of a super clean syntax for your great NPM library @jonschlinkert .
Usage
- In case of single attribute sort: sort asc with
string
and desc with-
+string
- In case of multiple attribute sort: add the attributes in an array with the same asc/desc functionality as above
Examples
Single attribute reverse (desc) sort:
let arr = [{foo: 'y'}, {foo: 'z'}, {foo: 'x'}]
arraySort(arr, '-foo')
// Will sort on attribute `foo` as `desc`
Multiple attribute asc & desc sort:
let arr = [{foo: 'y', bar: 'a'}, {foo: 'z', bar: 'b'}, {foo: 'x', bar: 'c'}, {foo: 'x', bar: 'a'}]
arraySort(arr, ['foo', '-bar'])
// Will sort on attribute `foo` as `asc`
// will sort next on `bar` as `desc`