# b7f7ca3a89d4f1c0173ea46478f3e2ba38f2ad96b960950171ccf618da410f1d Elan 1.7.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}
