SORTING ALGORITHM
n = array.length - 1
n.times.each do |l|
min_index = l
for j in (l+1)..n
min_index = j if array[j] < array[min_index]
end
array[l], array[min_index] = array[min_index], array[l] if min_index != l
end
array
end
sort_list([65,565656,43,3,2,1,0,9,6]) # to call the method
No comments:
Post a Comment