Collections.sort(ydShips, new Comparator<YdShip>() { @Override public int compare(YdShip o1, YdShip o2) { if(o1.getNumber()> o2.getNumber()){ //number是用来排序的列 return 1; }else if(o1.getNumber()==o2.getNumber()){ return 0; } return -1; } });
Collections.sort(ydShips, new Comparator<YdShip>() { @Override public int compare(YdShip o1, YdShip o2) { if(o1.getNumber()> o2.getNumber()){ //number是用来排序的列 return 1; }else if(o1.getNumber()==o2.getNumber()){ return 0; } return -1; } });