首页 > 代码库 > 对字符串进行排序

对字符串进行排序

@Test
public void demo8(){
String s = "678912345";
char[] charArray = s.toCharArray();
for(int x = 0;x < charArray.length; x++){
for(int y =0; y<charArray.length-1;y++){
if(charArray[x]<charArray[y]){
char c = charArray[x];
charArray[x] = charArray[y];
charArray[y] = c;
}
}
}
String valueOf = String.valueOf(charArray);
System.out.println(valueOf);
}

对字符串进行排序