# Algorithm-Quick Sort

Source: Internet
Author: User

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

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.