persuasion

    1.0.1 • Public • Published

    persuasion

    Wraps Array.sort to provide shortcuts to make sorting arrays that tiny bit less verbose

    Build Status

    NPM

    Media Suite

    Installation

    npm install persuasion
    

    Basic Usage

    var sort = require('persuasion')
    sort([3,4,2,1,6]) //=> [1,2,3,4,6]
    sort(['lol','rageguy','ateam','fry','troll']) //=> ['ateam','fry','lol','rageguy','troll']

    Sort in reverse

    Just add the config option reverse: true

    sort([3,4,2,1,6], {reverse: true}) //=> [6,4,3,2,1]

    Sort objects by property

    Use the config option property to specify which property to sort by

    var data = [
      { name: 'bob' },
      { name: 'tim' },
      { name: 'jim' },
      { name: 'ham' }
    ]
    sort(data, {property: 'name'})
    /*=>
    [
      { name: 'bob' },
      { name: 'jim' },
      { name: 'ham' },
      { name: 'tim' }
    ]
    */

    Keywords

    Install

    npm i persuasion

    DownloadsWeekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • digitalsadhu