blob: 3f919863f07149ce43cf1deb6eb09f8e70a4c9bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class InsertionSort
def sort(items)
items.size.times do |n|
j = n
while j >= 0 do
if (items[j] <=> items[j+1]) == 1
items[j], items[j+1] = items[j+1], items[j]
end
j-=1
end
end
items
end
end
|