This isn't a "true" selection sort technically. More of a "linear sort."
function minidx(ary)
(idx, elem) = (1, ary[1])
for (k, el) in enumerate(ary)
if el < elem
(idx, elem) = (k, el)
end
end
return idx
end
function linear_sort!(ary)
arr = copy(ary)
sorted_ary = Array{eltype(arr), 1}(undef, length(arr))
n = length(arr)
position = 1
while position ≤ n
sorted_ary[position] = popat!(arr, minidx(arr))
position += 1
end
return sorted_ary
end