TopCoder problem "SortInsideNumber" used in TCHS07 Semifinal (Division I Level One)



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

0)
    
2143
Returns: 4321
1)
    
999998999
Returns: 999999998
2)
    
61423
Returns: 64321
3)
    
500613009
Returns: 965310000

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7803

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10763&pm=7803

Writer:

VitalyGoldstein

Testers:

PabloGilberto , brett1479 , Cosmin.ro , Olexiy

Problem categories:

Sorting