Skip to content

Instantly share code, notes, and snippets.

@KCreate
Created December 29, 2016 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KCreate/c354bfabebf96f899ff8f59b1a5c36fe to your computer and use it in GitHub Desktop.
Save KCreate/c354bfabebf96f899ff8f59b1a5c36fe to your computer and use it in GitHub Desktop.
Bubblesort algorithm written in charly.
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