Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (15 sloc) 344 Bytes
def selection_sort(collection)
length = collection.length
for i in 0..length - 2
min_index = i
for j in (i + 1)...length
if collection[j] < collection[min_index]
min_index = j
end
end
tmp = collection[i]
collection[i] = collection[min_index]
collection[min_index] = tmp
end
collection
end
You can’t perform that action at this time.