compound-sort
Create a compound sort / comparator function from one or more comparators
Last updated 5 years ago by ashaffer88 .
MIT · Original npm · Tarball · package.json
$ cnpm install compound-sort 
SYNC missed versions from official npm registry.

compound-sort

Create a compound sort / comparator function from one or more comparators

Example

function cmpa(a, b) {
  return a.a < b.a ? -1 : (a.a === b.a ? 0 : 1)
}

function cmpb(a, b) {
  return a.b < b.b ? -1 : (a.b === b.b ? 0 : 1)
}

//
// Returns a function that compares first by cmpa, then by cmpb
// for values that tie with respect to cmpa
//
compound(cmpa, cmpb)

Current Tags

  • 0.1.1                                ...           latest (5 years ago)

1 Versions

  • 0.1.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |