Created
December 29, 2016 19:29
-
-
Save KCreate/c354bfabebf96f899ff8f59b1a5c36fe to your computer and use it in GitHub Desktop.
Bubblesort algorithm written in charly.
This file contains 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
Array.methods.sort = ->{ | |
let sorted = @copy() | |
let left | |
let right | |
@length().times(func(i) { | |
(@length() - 1).times(func(y) { | |
left = sorted[i] | |
right = sorted[y] | |
if (left > right) { | |
sorted[i] = right | |
sorted[y] = left | |
} | |
}) | |
}) | |
sorted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment