Skip to content

Instantly share code, notes, and snippets.

@srph
Created February 10, 2017 09:48
Show Gist options
  • Select an option

  • Save srph/483d07b02b5c61704bfae925b6465f1c to your computer and use it in GitHub Desktop.

Select an option

Save srph/483d07b02b5c61704bfae925b6465f1c to your computer and use it in GitHub Desktop.
JS: Sort ascending, but sort invalid ones (0 in this case) to the end
[0,5,8,1,3,1,6].sort((a, b) => a === 0 ? true : a > b);
// // [1, 1, 3, 5, 6, 8, 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment