id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > sortNum
prev  |  next  |  chance

Write a method that accepts a positive integer parameter and returns that value as an integer, but "sorted" to have its digits in increasing order. For example, sortNum(72081) would return 1278 since the increasing order of the digits would be 0, 1, 2, 7, and 8, but the zero is not significant when placed as the first digit. There are several interesting ways of solving this problem, so you might want to look for alternative solutions after you solve it one way.


sortNum(7823) → 2378
sortNum(18424) → 12448
sortNum(4000) → 4

...Save, Compile, Run (ctrl-enter)

public int sortNum(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy