Although many languages now encapsulate different data structures in the sorting method, but in different scenarios there will always be a number of algorithms that do not have a ready-made sorting algorithm, which requires the programmer to quickly handwritten sorting algorithm.
A fast sorting algorithm based on list<map> implementation.
A list of references to the existing list<map> requires ordering according to the value of List.get (i). Get ("value"), which is sorted by a field of MAP
PrivateList<map> QuickSort (list<map> List, String SortKey,intLeftintRight ) { returnQuick_sort (list,sortkey,left,right);}PrivateList<map> Quick_sort (list<map> List, String SortKey,intLeftintRight ) { if(Left <Right ) {Map key=List.get (left); intLow =Left ; intHigh =Right ; while(Low <High ) { while(Low < High && list.get (high). Get (SortKey) >=Key.get (SortKey)) { High--; } list.set (Low,list.get (high)); while(Low < High && list.get (Low). Get (SortKey) <=Key.get (SortKey)) { Low++; } List.set (High,list.get (Low)); } list.set (Low,key); List<Map> listsortleft = Quick_sort (list,sortkey,left,low-1); List<Map> listsortright = Quick_sort (Listsortleft, sortkey,low+1, right); returnListsortright; } returnlist;}
Algorithm-Quick Sort