# 6aebb20430dab472bb39ab7fb4dfa838b1990369b4557e9e5709fa19dbf202c5 Elan 1.6.1 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}
