Java-based sorting of Map sets
Step 1: Add a temporary sort key to Map
// Initialize the Map set List
> Columns = new ArrayList
> (); Map
C1 = new HashMap
(); C1.put (sort, 8); c1.put (title, www.chuweibo iao.com); columns. add (c1); Map
C2 = new HashMap
(); C2.put (sort, 5); c2.put (title, www.chuweibo iao.com); columns. add (c2); Map
C3 = new HashMap
(); C3.put (sort, 13); c3.put (title, www.chuweibo iao.com); columns. add (c3 );
Step 2: Sort
/*** Sort Map-type element sets * @ param columns * Map-type Element Set */private void listSortingForMapTypeElement (List
> Columns) {Collections. sort (columns, new Comparator
> () {Public int compare (Map
Last, Map
Next) {Object lastSort = last. get (sort); Object nextSort = next. get (sort); if (lastSort = null | nextSort = null) {return 0;} else {return Integer. parseInt (String. valueOf (lastSort)> Integer. parseInt (String. valueOf (nextSort ))? 1: 0 ;}}});}
Step 3: remove the temporary key
/*** Remove the temporary sorting key * @ param columns * Map type Element Set */private void removeSortKey (List
> Columns) {for (Map
Column: columns) {column. remove (sort );}}