Method: Array#swap

Defined in:
lib/food/sort.rb

#swap(i, j) ⇒ Object

Swap changes elements in position!



4
5
6
7
8
# File 'lib/food/sort.rb', line 4

def swap(i, j)
  clone_array = self.clone
  clone_array[i], clone_array[j] = clone_array[j], clone_array[i]
  clone_array
end