lib/bubble_sort.rb
def bubble_sort!
    sorted = false
    until sorted
      sorted = true

      self.each_with_index do |el, i|
        next if i + 1 == self.length
        j = i + 1
        if self[i] > self[j]
          sorted = false
          self[i], self[j] = self[j], self[i]
        end
      end
    end
    self
  end
# Write an Array method that returns a bubble-sorted copy of an array.
# Do NOT call the built-in `Array#sort` or `Array#sort_by` methods in
# your implementation.
Write an Array method that returns a bubble-sorted copy of an array.
Do NOT call the built-in `Array#sort` or `Array#sort_by` methods in
your implementation.
Write an Array method that returns a bubble - sorted copy of an array . Do NOT call the built - in ` Array#sort ` or ` Array#sort_by ` methods in your implementation .
def bubble_sort!
    sorted = false
    until sorted
      sorted = true
      self.each_with_index do |el, i|
        next if i + 1 == self.length
        j = i + 1
        if self[i] > self[j]
          sorted = false
          self[i], self[j] = self[j], self[i]
        end
      end
    end
    self
  end
def bubble_sort! sorted = false until sorted sorted = true self . each_with_index do | el , i | next if i + 1 == self . length j = i + 1 if self [ i ] > self [ j ] sorted = false self [ i ] , self [ j ] = self [ j ] , self [ i ] end end end self end
Write an Array method that returns a bubble-sorted copy of an array.
Write an Array method that returns a bubble - sorted copy of an array .