sort-array-by-another
Sort an array, then apply the same steps to another array.
Installing
npm install sort-array-by-another
Usage
Let's assume we have arrays of properties:
const names = 'boris' 'ada' 'charles'const student = false true trueconst ages = 20 10 30
For performance reasons, we won't use an array of objects, but use sort-array-by-another
instead:
const recordSort = const applySort = // [true, false, true]// ['ada', 'boris', 'charles']
Using sortArrayByAnother
, you can sort items
the same way that Array.prototype.sort
will sort model
:
Related
array-rearrange
– Rearrange array elements by index.
Contributing
If you have a question or have difficulties using `sort-arrays-by-another, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.