This commit is contained in:
Vitor Oliveira 2021-04-24 23:21:08 -07:00
parent 812a8e42af
commit 42dafdfe7a

View file

@ -34,12 +34,14 @@ def bubble_sort(array)
loop do
swapped = false
(array_length - 1).times do |i|
if array[i] > array[i + 1]
array[i], array[i + 1] = array[i + 1], array[i]
swapped = true
end
end
break unless swapped
end