Exact Order
Dead simple module for ordering by an explicit order weighing in at 1.3KB.
💡 Useful for when you have an array of dynamic data, but you need to sort by a set order, rather than a natural sort order, such as alphabetically or numerically.
npm i exact-order --save
Getting Started
Simply pass in either an array or map of the set order. For sorting on multiple properties you're able to pass in a map with multiple keys – with the relevance being from top-to-bottom.
; // Primitives.1 2 3; // [2, 1, 3] // Complex nested. value: 1 value: 2 value: 3 ; // [{ value: 2 }, { value: 1 }, { value: 3 }]