mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-11-16 19:50:00 +01:00
Removed unwanted index check
This commit is contained in:
parent
7b98525265
commit
4d89a333a8
1 changed files with 4 additions and 6 deletions
|
@ -5,12 +5,10 @@ def bubble_sort(array)
|
|||
sorted = false
|
||||
until sorted
|
||||
sorted = true
|
||||
for i in (0..unsorted_until_index)
|
||||
if array[i+1]
|
||||
if array[i] > array[i+1]
|
||||
array[i], array[i+1] = array[i+1], array[i]
|
||||
sorted = false
|
||||
end
|
||||
0.upto(unsorted_until_index - 1) do |i|
|
||||
if array[i] > array[i+1]
|
||||
array[i], array[i+1] = array[i+1], array[i]
|
||||
sorted = false
|
||||
end
|
||||
end
|
||||
unsorted_until_index -= 1
|
||||
|
|
Loading…
Reference in a new issue