What are the sorting methods?

Sorting methods are:

First, insert the sort directly.

Principle: Choose one of the numbers to be sorted and insert it in the appropriate position in front.

Second, choose sorting.

Contrary to direct insertion sorting, selective sorting is to select the smallest number from the numbers to be sorted and put it after the already sorted numbers. This algorithm is time-consuming.

Third, quick sorting.

Quick sort, referred to as quicksort, is a relatively fast sort, which is suitable for basically disordered data. Why do you say that? Let me talk about the idea of quick sorting: set two pointers: I and J, pointing to the first and last one respectively. I move back and forward, and choose the first number as the standard (usually the key to quick sorting is the choice of this "standard"), starting from the back.

Find the first number smaller than the standard, switch places, and then find the first number larger than the standard from the front, switch places. The result of the first trip is that the left side of the standard is smaller than the standard and the right side is larger than the standard (but not necessarily orderly). After dividing into two groups, continue to use the above method recursively, and finally orderly!

Fourth, bubble sorting

Bubble sorting is a very simple sorting algorithm, which is easy to understand and time. The idea is simple: small numbers bubble forward bit by bit, and finally sort.

Verbs (abbreviation for verb) merge and sort

Merge sorting is an effective sorting algorithm based on merge operation. This algorithm is a very typical application of divide and conquer.

First, consider how to merge two ordered sequences. This is very simple. Just compare the first number of two series, take the smaller number first, and then delete this number in the corresponding series. Then compare it. If a series is empty, you can directly fetch the data of another series in turn.