Skip to content

Instantly share code, notes, and snippets.

@mytrile
Created December 29, 2008 13:02
Show Gist options
  • Select an option

  • Save mytrile/41259 to your computer and use it in GitHub Desktop.

Select an option

Save mytrile/41259 to your computer and use it in GitHub Desktop.
def bsort(list)
slist = list.clone
for i in 0..(slist.length - 1)
for j in 0..(slist.length - i - 2)
if ( slist[j + 1] <=> slist[j] ) == -1
slist[j], slist[j + 1] = slist[j + 1], slist[j]
end
end
end
return slist
end
#Usage
# list = 6, 5, 9, 1, 2
# puts bsort(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment