Skip to content

Instantly share code, notes, and snippets.

@hassansw
Created March 6, 2019 06:43
Show Gist options
  • Save hassansw/0f608b9d5a43da6072fc4628d4cfc407 to your computer and use it in GitHub Desktop.
Save hassansw/0f608b9d5a43da6072fc4628d4cfc407 to your computer and use it in GitHub Desktop.
Order number to descending or ascending order
function descendingOrder(n){
const newArr = (n).toString(10).split("").map(Number);
return parseInt(newArr.sort(function (a, b) { return b - a }).join("")) // replace (b-a) to (a-b) for ascending order
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment