void sort(Object[] a, int fromIndex, int toIndex, Comparator c)
自己写一下Comparator我以前写过一个排序的
import javax.swing.*;public class sort {
public static void main(String[] args) {
String[] str = new String[11];
//input
for (int count = 1; count <= 10; count++) {
str[count] = JOptionPane.showInputDialog
("please input the " + count + " String:");
//sort
}
int i = 0;
int j = 0;
for (i = 2; i <= 10; i++) {
if (str[i].compareTo(str[i - 1]) < 0) {
str[0] = str[i];
str[i] = str[i - 1];
for (j = i - 2; str[0].compareTo(str[j]) < 0; j--) {
str[j + 1] = str[j];
}
str[j + 1] = str[0];
}
}
//output
for (int count = 1; count <= 10; count++) {
System.out.println(count + ";" + str[count]);
}
}
}
自己写一下Comparator我以前写过一个排序的
import javax.swing.*;public class sort {
public static void main(String[] args) {
String[] str = new String[11];
//input
for (int count = 1; count <= 10; count++) {
str[count] = JOptionPane.showInputDialog
("please input the " + count + " String:");
//sort
}
int i = 0;
int j = 0;
for (i = 2; i <= 10; i++) {
if (str[i].compareTo(str[i - 1]) < 0) {
str[0] = str[i];
str[i] = str[i - 1];
for (j = i - 2; str[0].compareTo(str[j]) < 0; j--) {
str[j + 1] = str[j];
}
str[j + 1] = str[0];
}
}
//output
for (int count = 1; count <= 10; count++) {
System.out.println(count + ";" + str[count]);
}
}
}
java.util.Arrays.sort(card);