Created
March 13, 2018 07:58
-
-
Save mornir/0dca37ce8e1262a9847e0a7073714636 to your computer and use it in GitHub Desktop.
sorting array of objects
This file contains hidden or 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
function sortListBy(Parameter, List) { | |
return List.sort((a, b) => { | |
if (a[Parameter] > b[Parameter]) { | |
return 1 | |
} else { | |
return -1 | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment