Sort a String in Java

A string can be sorted easily by converting to character array and using the Arrays class.

String original = "test a string 123";
char[] chars = original.toCharArray();
Arrays.sort(chars);
String sorted = new String(chars);
System.out.println(sorted);

Output

123aeginrssttt