Anonymous user
Sorting algorithms/Selection sort: Difference between revisions
m
→{{header|Ruby}}: correct a couple of typos
(→{{header|Ruby}}: use idiomatic Ruby) |
m (→{{header|Ruby}}: correct a couple of typos) |
||
Line 2,684:
puts "sequential_sort([9, 6, 8, 7, 5]): #{sequential_sort([9, 6, 8, 7, 5])}"
# more efficient version - swaps the array's elements in place
def sequential_sort_with_swapping(array)
array.each_with_index do |element, index|
Line 2,705 ⟶ 2,709:
end
puts "sequential_sort_with_swapping([
# prints: sequential_sort_with_swapping([7,6,5,9,8,4,3,1,2,0]): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
▲# => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</lang>
=={{header|Run BASIC}}==
|