Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Last active July 16, 2018 14:37
Show Gist options
  • Save kaleem-elahi/d274a4668c84a197a93dea8f63afd93e to your computer and use it in GitHub Desktop.
Save kaleem-elahi/d274a4668c84a197a93dea8f63afd93e to your computer and use it in GitHub Desktop.
sorting data with string and number in object
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