import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; public static void main(String[] args) { List<Object> list = new ArrayList<>(); list.add(1); list.add(12); list.add(122); list.add(13); list.add(4); System.out.println("排序前:"+list); Collections.sort(list, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { if(((Integer)o1 - (Integer)o2)>0){ return 1; }else { return -1; } } }); System.out.println("排序后:"+list); }