Last active
August 6, 2021 01:56
-
-
Save kosinix/751d6094ca3656018b17114dc1e9691f to your computer and use it in GitHub Desktop.
Lodash Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sort array based on array of sorted IDs | |
let unsorted = [ | |
{ | |
id: 'bcd' | |
}, | |
{ | |
id: 'abc' | |
} | |
] | |
let idsArray = ['abc', 'bcd'] | |
let sorted = lodash.sortBy(unsorted, (o) => { | |
return idsArray.indexOf(o.id) | |
}); | |
// [ { id: 'abc' }, { id: 'bcd' } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment