Guest User

Untitled

a guest
Aug 17th, 2019
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function insertionSort() {
  3. $ary = [5, 2, 4, 6, 1, 3];
  4. for($j = 1; $j < count($ary); $j++) {
  5. $key = $ary[$j];
  6. $i = $j-1;
  7. while($i >= 0 && $ary[$i] > $key) {
  8. $ary[$i+1] = $ary[$i];
  9. $i = $i-1;
  10. $ary[$i+1] = $key;
  11. }
  12. }
  13. }
  14. ?>
RAW Paste Data