This package has been deprecated

Author message:

Development of this module has been stopped.

ckeys

3.0.2 • Public • Published

ckeys

Build Status js-standard-style

Return a compare function (to compare object's keys) to use in an Array's .sort() function

Installation

$ npm install --save ckeys

Usage

ckeys(key)

var ckeys = require('ckeys')
 
var array = [
  {text: 'a', num: 7},
  {text: 'b', num: 1},
  {text: 'c', num: 23},
  {text: 'd', num: 79}
]
 
array.sort(ckeys('num'))
 
/*
 
[ { text: 'b', num: 1 },
  { text: 'a', num: 7 },
  { text: 'c', num: 23 },
  { text: 'd', num: 79 } ]
 
*/
 
array.sort(ckeys('num', true))
 
/*
 
[ { text: 'd', num: 79 },
  { text: 'c', num: 23 },
  { text: 'a', num: 7 },
  { text: 'b', num: 1 } ]
 
*/

Readme

Keywords

Package Sidebar

Install

npm i ckeys

Weekly Downloads

1

Version

3.0.2

License

MIT

Unpacked Size

3 kB

Total Files

4

Last publish

Collaborators

  • roryrjb