← Back to challenges

Sort Numbers in Descending Order

JavaScriptHardformattingsortingnumbers

Instructions

Create a function that takes any nonnegative number as an argument and return it with it's digits in descending order. Descending order is when you sort from highest to lowest.

Examples

sortDescending(123) ➞ 321

sortDescending(1254859723) ➞ 9875543221

sortDescending(73065) ➞ 76530

Notes

You can expect non-negative numbers for all test cases.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Transform into an Array with No Duplicates