How to sort arrays from small to large by php
Most people don't understand the knowledge points of this article "how to implement array sorting from small to large in php", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "how to implement array sorting from small to large in php".
1. Description
Bubble sort is a simple sort algorithm. The name of this algorithm comes from the fact that smaller elements float slowly to the top of the sequence by swapping.
2, the use of methods
Compare adjacent elements. If the first one is bigger than the second one, switch to two.
Each pair of adjacent elements does the same job, from the first pair to the last pair. At this point, the final element should be.
Repeat the above steps for all elements except the last step.
Repeat the above steps each time until there are no pairs of numbers to compare.
3. Examples