String lotteryResult = "231"
//字符串转char数组
char[] lotteryResultArray = lotteryResult.toCharArray();
//用Arrays进行排序
Arrays.sort(lotteryResultArray);
//char 数组转String
String newLotteryResult = String.valueOf(lotteryResultArray);
字符串转char数组用了字符串的toCharArray()方法,排序时用了Arrays工具类中的sort排序方法,最后用String.valueOf强转字符串