Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax suggestion #12

Open
mesqueeb opened this issue Mar 5, 2018 · 0 comments
Open

Syntax suggestion #12

mesqueeb opened this issue Mar 5, 2018 · 0 comments

Comments

@mesqueeb
Copy link
Contributor

mesqueeb commented Mar 5, 2018

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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant