Sort Numbers in Descending Order

Published by Alex Golubov in

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

Examples

sortDescending(123) ➞ 321

sortDescending(2619805) ➞ 9865210

sortDescending(73065) ➞ 76530

Notes

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

Watch a quick demo on how Edabit works.