Problem Statement
It is easy to sort an array of integers, but more difficult to sort the digits within an integer. You are given an int x. Sort the digits in x in non-ascending order, and return the resulting int.
Definition
- Class:
- SortInsideNumber
- Method:
- sort
- Parameters:
- int
- Returns:
- int
- Method signature:
- int sort(int x)
- (be sure your method is public)
Constraints
- x will be between 1 and 1000000000, inclusive.
Examples
2143
Returns: 4321
999998999
Returns: 999999998
61423
Returns: 64321
500613009
Returns: 965310000