mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-11-16 19:50:00 +01:00
enter
This commit is contained in:
parent
812a8e42af
commit
42dafdfe7a
1 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue