Refactored dashboard sort logic.
This commit is contained in:
@@ -9,3 +9,10 @@ export function chunk(arr, size) {
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
export function sortArrayByMap(arr, map = [], key) {
|
||||
if (!arr) return [];
|
||||
if (map.length === 0) return arr;
|
||||
|
||||
return map.map(id => arr.find(item => item[key] === id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user