import util.control.Breaks._ object Main { def pp(ary: Array[Int]) { val s = ary.mkString(",") } def digits(n: Int): Array[Int] = { val s = n.toString.chars.toArray.map(e => e - '0'.toInt) s } def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val s = sc.nextInt var ds = digits(s) breakable { for (i <- 0 to ds.length-1) { var swap = false var c = ds(i) var index = i for (j <- i to ds.length-1) { if (ds(i) < ds(j) && c <= ds(j)) { c = ds(j) index = j } } if (index > i) { val t = ds(i) ds(i) = ds(index) ds(index) = t break } } } println(ds.mkString) } }