Last active
July 16, 2018 14:37
-
-
Save kaleem-elahi/d274a4668c84a197a93dea8f63afd93e to your computer and use it in GitHub Desktop.
sorting data with string and number in object
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
export const getMultiSortedValues = (arr, key, num) => | |
arr.sort((a, b) => { | |
if (a[num] === b[num]) return a[key].localeCompare(b[key]); | |
return b[num] - a[num]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment