Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -0,0 +1,17 @@
|
|||
class Array
|
||||
def bubble_sort!
|
||||
i = size - 1
|
||||
while i > 0
|
||||
(1..i).each do |j|
|
||||
swap(j, j-1) if self[j] < self[j-1]
|
||||
end
|
||||
i -= 1
|
||||
end
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
arr = Array.new(20) { rand 100 }
|
||||
|
||||
p arr
|
||||
p arr.bubble_sort!
|
||||
Loading…
Add table
Add a link
Reference in a new issue