Module: Ruborithms::Algorithms::SelectionSort::ClassMethods

Defined in:
lib/ruborithms/algorithms/selection_sort.rb

Instance Method Summary collapse

Instance Method Details

#selection_sort(object) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ruborithms/algorithms/selection_sort.rb', line 11

def selection_sort(object)
  0.upto(object.count - 1) do |i|
    min_value_index = find_index_of_min_value(object, i)
    swap(object, i, min_value_index)
  end
  object
end