Skip to content

Instantly share code, notes, and snippets.

@trkrameshkumar
Last active April 29, 2017 13:44
Embed
What would you like to do?
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