0.0.1 • Published 8 years ago

arrchunksort v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

arrchunksort

Sort array by chunks

INSTALL

npm install arrchunksort

API

var chunksort = require('arrchunksort')
chunksort(array, chunksize, compare)

SHOW CASES

chunksort([3, 2, 1, 4])

Result: 1, 2, 3, 4

chunksort([3, 2, 1, 4], 2)

Result: 1, 4, 3, 2

chunksort([4, 2, 3, 1], 2)

Result: 3, 1, 4, 2

chunksort(
  [4, 1, 3, 2], 2,
  function (a, b) {
    if (a[0] > b[0]) return -1
    if (a[0] < b[0]) return 1
    return 0
  }
)

Result: 4, 1, 3, 2