def n = 7876541def newN = n.toString().split('').findAll{it}.sort().reverse().join()println newN
Standard input is empty
8776541
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!