Rubyで選択ソート

選択ソート

# a: int型の配列
# n: 配列の大きさ

def selectionSort(a, n)
  min_index = 0
  (0..n-1).each do |i|
    min_index = i
    (i..n-1).each do |j|
      if a[j] < a[min_index]
        min_index = j
      end
    end
    if a[min_index] < a[i]
      tmp = a[i]
      a[i] = a[min_index]
      a[min_index] = tmp
    end
  end
end