k.php 323 B

1234567891011121314151617
  1. <?php
  2. function bubblesort_once($a) {
  3. $clone = array_replace([], $a);
  4. if (count($clone) < 2) {
  5. return $clone;
  6. }
  7. for ($i = 0; $i < count($clone) - 1; $i++) {
  8. if ($clone[$i] > $clone[$i + 1]) {
  9. $tmp = $clone[$i+1];
  10. $clone[$i+1] = $clone[$i];
  11. $clone[$i] = $tmp;
  12. }
  13. }
  14. return $clone;
  15. }