多分これはあなたの混乱を助けることができます:
public class Test {
public static A a1 = new A("001", "a", "wa~", 7);
public static A a2 = new A("001", "c", "wa~", 9);
public static A a3 = new A("001", "b", "wa~", 3);
public static A a4 = new A("000", "d", "wa~", 6);
public static void main(String[] args) {
A[] voA = new A[] { a1, a2, a3, a4 };
java.util.Arrays.sort(voA, new Mycomparator());
A[] newA = new A[voA.length];
for (int i = 0; i < voA.length; i++)
System.out.println("[" + i + "]:" + voA[i].A1 + " " + voA[i].A2 + " " + voA[i].A3 + " " + voA[i].A4);
}
}
class A {
String A1;
String A2;
String A3;
int A4;
public A(String oA1, String oA2, String oA3, int oA4) {
this.A1 = oA1;
this.A2 = oA2;
this.A3 = oA3;
this.A4 = oA4;
}
}
class Mycomparator implements java.util.Comparator {
public int compare(Object o1, Object o2) {
A a1 = (A) o1;
A a2 = (A) o2;
if(a1.A1.compareTo(a2.A1)!=0) {
return a1.A1.compareTo(a2.A1);
} else if(a1.A2.compareTo(a2.A2)!=0) {
return a1.A2.compareTo(a2.A2);
} else if(a1.A3.compareTo(a2.A3)!=0) {
return a1.A3.compareTo(a2.A3);
} else {
return a1.A4 >a2.A4?1:a1.A4==a2.A4?0:-1;
}
}
}