: This article mainly introduces php-insert sorting. if you are interested in the PHP Tutorial, refer to it.
$ List = array (,); $ list = insert_sort ($ list); var_dump ($ list); function insert_sort ($ array) {$ return = array (); for ($ I = 0, $ count = count ($ array); $ I <$ count; $ I ++) {$ last = true; for ($ j = 0, $ size = count ($ return); $ j <$ size; $ j ++) {if ($ return [$ j]> $ array [$ I]) {$ last = false; $ m = $ size; while ($ m> $ j) {$ return [$ m] = $ return m-1]; $ m --;} $ return [$ j] = $ array [$ I]; break ;}} if ($ last) {$ return [] = $ array [$ I] ;}} return $ return;} function insertsort ($ arr1, $ max = 11) {for ($ I = 1; $ I <= $ max; $ I ++) {$ tmp = $ arr1 [$ I]; $ j = $ I-1; while ($ j> = 0 & $ tmp <$ arr1 [$ j]) {$ arr1 [$ j + 1] = $ arr1 [$ j]; $ j --;} $ arr1 [$ j + 1] = $ tmp;} return $ arr1 ;}
The above describes the php-insert sorting, including the content, and hope to be helpful to friends who are interested in the PHP Tutorial.