You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
def insertion_sort(a)
|
|
(0..(a.length - 1)).each do |j|
|
|
key = a[j]
|
|
i = j - 1
|
|
while (i >= 0) && (a[i] > key)
|
|
a[i + 1] = a[i]
|
|
i = i - 1
|
|
end
|
|
a[i + 1] = key
|
|
end
|
|
end
|
|
|