Skip to content

Instantly share code, notes, and snippets.

@BennoCrafter
Created February 21, 2023 14:14
Show Gist options
  • Save BennoCrafter/373bd5bf389a294a0dec3fd6a434c399 to your computer and use it in GitHub Desktop.
Save BennoCrafter/373bd5bf389a294a0dec3fd6a434c399 to your computer and use it in GitHub Desktop.
simple bubble sort with oasis
do(
define(arr, "289435028342847959"),
define(n, len(arr)),
define(swapped, "true"),
while(==(swapped, "true"),
do(
define(swapped, "false"),
define(i, 0),
while(<(i, -(n,1)),
do(
if(>(charAt(arr,i), charAt(arr, +(i,1))),
do(
define(temp, charAt(arr,i)),
define(arr, replace(arr, i, charAt(arr, +(i,1)))),
define(arr, replace(arr, +(i,1), temp)),
define(swapped, "true")
)
),
define(i, +(i,1))
)
),
define(i, -(i,1))
)
),
out(arr)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment