# d0d1ca900428b0655a0a52bee0319f4de5f98f880d3445b0ac1dc2faab4075d4 Elan 1.8.0 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}
