Home >Backend Development >PHP Tutorial >PHP sorting algorithm (bubble sort, quick sort)_PHP tutorial
Bubble sort implementation principle
① First put all the numbers to be sorted into the work list.
② From the first number to the second to last number in the list, check one by one: if the number on a certain digit is greater than its next digit, swap it with its next digit.
③ Repeat step ② until no more exchanges are possible.
Code implementation
';<br> print_r(bubbingSort(array(1,4,22,5,7,6,9) ));<br> print '';
Copy code
';<br> print_r(quickSort(array(1,4,22,5,7,6,9))) ;<br> print '';