Skip to content

Instantly share code, notes, and snippets.

@novonimo
Last active September 13, 2019 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save novonimo/32f642aa4cfd7e9d1cb408f32563d563 to your computer and use it in GitHub Desktop.
Save novonimo/32f642aa4cfd7e9d1cb408f32563d563 to your computer and use it in GitHub Desktop.
introduce to sort HOC
const listOfNumbers = [4, 5, 8, 1, 0, 2, 7, 3]
const sortedList = listOfNumbers.sort((n1, n2) => {
if (n1 > n2) {
return 1;
} else {
return -1;
}
})
const mySortedList = listOfNumbers.sort((a, b)=> a > b ? 1 : -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment