println System.in.readLines()*.split(" ")*.sort{a,b -> a+b <=> b+a }.collect{"${it.collect().swap(0,Math.max(0,it.findIndexOf{n->n>'0'})).join()} ${it.reverse().join()}"}.join("\n")
79 82 34 83 69 420 34 19 71 341 17 32 91 7 46 0 1 2
3469798283 8382796934 193413442071 714203434119 173246791 917463217 102 210
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!