Site icon 咖啡偶-IT日常

sort your array (java)

1:
ArrayList aArrayList = new ArrayList

2:
public YourClass implements Comparator {


private int id;
public int getID(){
return id;
}
public int compare(YourClass o) {
return this.getID()-o.getID();
}
}

3:
Collections.sort(aArrayList );

Exit mobile version