# 72842eda6b1c942a51f1a7a5b22bf8656c72a129d970dc269eda3741251b7b1b Elan 1.6.4 guest default_profile valid

main
  variable li set to example.asList()
  call inPlaceRippleSort(li)
  print li
end main

procedure inPlaceRippleSort(out arr as List<of Int>)
  variable changes set to true
  variable lastComp set to arr.length() - 2
  repeat
    set changes to false
    for i from 0 to lastComp step 1
      if arr[i] > arr[i + 1] then
        let temp be arr[i]
        call arr.putAt(i, arr[i + 1])
        call arr.putAt(i + 1, temp)
        set changes to true
      end if
    end for
    set lastComp to lastComp - 1
  end repeat when not changes
end procedure

constant example set to {3, 6, 1, 0, 99, 4, 67}
