Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created January 21, 2009 01:58
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 ukstudio/49811 to your computer and use it in GitHub Desktop.
Save ukstudio/49811 to your computer and use it in GitHub Desktop.
module Enumerable
def bubblesort!
return self if self.size <= 1
(self.size - 1).downto(0) do |i|
0.upto(i - 1) do |j|
self[j+1], self[j] = self[j], self[j+1] if self[j] > self[j+1]
end
end
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment