Created
March 24, 2022 21:29
-
-
Save mwhooker/d3e029511400078c4a4eb2ca0b0f7335 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tosort = [7, 8, 9, 4, 7, 6, 3, 6, 6, 5] | |
sort = func(arr){ | |
less = [] | |
equal = [] | |
greater = [] | |
r = [] | |
if length(arr) <= 1 { | |
return arr | |
} | |
pivot = arr[0] | |
for arr as x { | |
if x < pivot { | |
append(less, x) | |
} | |
if x == pivot { | |
append(equal, x) | |
} | |
if x > pivot { | |
append(greater, x) | |
} | |
} | |
append(r, sort(less)) | |
append(r, equal) | |
append(r, sort(greater)) | |
return r | |
} | |
print(sort(tosort)) | |
main = rule { true } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment