Package Exports
- sort-ids
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sort-ids) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sort-ids

Sort input array, return sorted ids of the array items, keeping the initial array unchanged.
Useful to perform linked sorting of multiple arrays, where linked array[s] should be sorted the same way as the primary one.
var sort = require('sort-ids')
var reorder = require('array-rearrange')
var rates = [.12, .47, .52, .97, ...sourceNumbers]
var names = ['John', 'Alexa', 'Jimmy', 'Kate', ...linkedItems]
var ids = sortIds(rates)
var sortedRates = reorder(a, ids)
var sortedNames = reorder(b, ids)See also array-rearrange for reordering input array based on a list of ids.
Motivation
This package is >= 6 times faster compared to sorting function. That is achieved by packing input value - id pairs into a single float64 value and performing native sort on that Float64Array, then unpacking the ids back.
Acknowledgement
The idea was proposed by Robert Monfera for snap-points-2d and eventually implemented. But there may be other applications, like sorting colors etc.
License
(c) 2018 Dmitry Yv. MIT License
