Skip to content

Instantly share code, notes, and snippets.

@trkrameshkumar
Last active April 29, 2017 13:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save trkrameshkumar/035c043977f098580fdcdd82d969e329 to your computer and use it in GitHub Desktop.
Bubble sort in Ruby
def bubble_sort array
(array.length-1).times do |i|
(array.length-1-i).times do |j|
if array[j] > array[j+1]
array[j], array[j+1]=array[j+1], array[j]
end
end
end
array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment