Quick actions

cmd+k|ctrl+k

Navigation

Languages

2018RubySelectionSort

Snippet info

Language

Ruby

Visibility

public

Author

mhcrnl

Created

2018-10-04T08:56:35Z

Updated

2018-10-04T09:09:12Z

puts "Hello World from Ruby selection Sort!"

def selectionSort(arr) 
    for k in 0...(arr.length- 1)
    min = k
        for j in (k+1)...arr.length
            min=j if arr[j]<arr[min]
        end
        arr[k], arr[min] = arr[min], arr[k]
    end
end

nums = [8,45, 67,90,4,67,89]
selectionSort(nums)
p nums
INFO