Knowledge points involved: if the title owner can smile ~~~ Data is processed today. The processed data is stored in List (). The elements in the list are HashMap <String, Object>. The element map contains three key-value pairs: id, name, num. it mainly deals with the number of occurrences of each element, and the subsequent num is the number of occurrences. The requirement is to put the data that appears more frequently at the front. You need to write a comparison class to implement the java. util. Comparator interface. Use Collections. sort (list, comparator); for comparison. Code: ① [java] public static void main (String [] args) {List <HashMap <String, Object> list = new ArrayList <HashMap <String, object >>> (); HashMap <String, Object> map = new HashMap <String, Object> (); map. put ("name", "gjk"); map. put ("id", "1"); map. put ("num", 45); list. add (map); HashMap <String, Object> map2 = new HashMap <String, Object> (); map2.put ("name", "gjk2"); map2.put ("id ", "2"); map2.put ("num", 60); List. add (map2); HashMap <String, Object> map3 = new HashMap <String, Object> (); map3.put ("name", "gjk3"); map3.put ("id ", "3"); map3.put ("num", 30); list. add (map3); // print the value in the list // printList (list); ComparatorHashMap comparator = new ComparatorHashMap (); Collections. sort (list, comparator); System. out. println ("after @"); // print the value in the list. // printList (list);} The comparison class is as follows, you can make changes based on your business needs: ② [java] public Class ComparatorHashMap implements Comparator {public int compare (Object arg0, Object arg1) {HashMap <String, Object> map = (HashMap <String, Object>) arg0; HashMap <String, object> map2 = (HashMap <String, Object>) arg1; // compares the number of occurrences. If the number is the same, the comparison name Integer num = Integer. parseInt (map. get ("num "). toString (); Integer num2 = Integer. parseInt (map2.get ("num "). toString (); int flag = num2.compareTo (num); if (flag = 0) {return (map2.get ("name "). toString ()). compareTo (map. get ("name "). toString () ;}else {return flag ;}③ sorting involves both positive and inverted sorting, which must be processed in your own implementation class. If it is positive sorting, compare the first value and the second value; if it is inverted sorting, compare the second value and the first value, and the two are reversed.