First, the sorting method for an array element is summarized in the following three ways:
1. Insert Sort
2. Select Sort
3. swap sort, that is, bubble sort
Next, they are discussed separately:
1. Insert Sort
Algorithm idea: Each step inserts a pending element into the sorted sequence at the appropriate position by the size of its key value until the sorted element is inserted.
Algorithm implementation:
Test results:
2. Select sort
Algorithm idea: Select the smallest element of a keyword each time from the sequence to be sorted (when you need to sort by the keyword in ascending order), and the sequence is sorted at the end of the ordered sequence until all the rows are complete.
Algorithm implementation:
Test results:
3. Swap sort (bubble sort)
Algorithm idea: 22 compares the elements in the sequence to be sorted and swaps the pairs of elements that do not meet the order requirements until all the order requirements are met.
Algorithm implementation:
Test results:
Summary of methods for sorting array elements (using C + +)