Sorting algorithm can be divided into internal sorting and external sorting , Internal sorting is the sorting of data records in memory , The external sorting is due to the large data , Cannot hold all sorting records at one time , External storage needs to be accessed during sorting .

Basic ideas adopted for various internal sorting ( strategy ) It can be divided into ： Insert sort , Exchange sort , Select sort , Merge sort and cardinality sort , Their basic strategy is ：

1, Insert sort
： One record in an unordered sequence in turn , Inserts the size of the key value into the appropriate position of a sequenced subsequence , Until all records are inserted . Specific methods include ： Direct insertion , Table insert ,2- Road insertion and shell sort .

2, Exchange sort
： For records in the sequence of records to be sorted , Keywords of pairwise comparison records , And exchange the two records in reverse order , Until there is no even pair of records in reverse order in the whole sequence . Specific methods include ： Bubble sorting , Quick sort .

3, Select sort ： Continuously select the record with the smallest keyword from the record sequence to be sorted , Placed at the end of a sequenced sequence , Until all records are selected . Specific methods include ： Simple selection sorting , Heap sort .

4, Merge sort ： utilize “ Merge ” Technology continuously merges the ordered subsequences in the ordered record sequence , Until combined into an ordered sequence .

5, Cardinality sort
： Composition of keywords by records to be sorted (“ position ”) From low to high ( Or from high to low ) conduct . Each time by record key “ position ” The value of allocates all records to the corresponding bucket , Then collect the records according to the number of barrels , Finally, we get an ordered sequence .

Common internal sorting algorithms include ： Insert sort (insertion sorting), Shell Sort (Shell Sort), Select sort (Selection
sort), Heap sort (Heapsort), Bubble sorting (Bubble Sort), Quick sort (quick sort), Merge sort (Merge