TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

SortInsideNumber

Problem statement, definition, constraints, and public examples.

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

  1. 2143
    Returns: 4321
  2. 999998999
    Returns: 999999998
  3. 61423
    Returns: 64321
  4. 500613009
    Returns: 965310000
Back to all problems