Skip to content

Instantly share code, notes, and snippets.

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
You can’t perform that action at this time.