I have a custom type Position(x,y,z),now I create a ArrayList, i want to sort this array ordered by the value of z, from small to b
Position(x,y,z)
ArrayList
try
Collections.sort(SortList, new Comparator(){ public int compare(Position p1, Position p2) { return p1.z- p2.z; } });