//需要排序的list List<T> list= new ArrayList<>(); //开始排序 Collections.sort(list, new Comparator<T>(){ public int compare(T o1, T o2) { //排序属性 if(o1.getNum() < o2.getNum()){ return 1; } if(o1.getNum() == o2.getNum()){ return 0; } return -1; } }); //排序完成 输出 System.out.println(new Gson().toJson(list))