Sha256: 5337c805e9c429338df407e8a37575a17e9aff0d9c125802fa1764e7f76603a2

Contents?: true

Size: 356 Bytes

Versions: 4

Compression:

Stored size: 356 Bytes

Contents

def bubble(numbers)
  for i in (0..numbers.size-1)
    for j in (i..numbers.size-1)
      if numbers[i] > numbers[j]
        temp = numbers[i]
        numbers[i] = numbers[j]
        numbers[j] = temp
      end
    end
  end
  numbers
end

input = STDIN.gets.split(" ").collect {|i| i.to_i}

bubble(input)

print input.inject {|output, n| "#{output} #{n}"}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jeka-0.2.3 test/bubble_sort/ruby/bubble_sort.rb
jeka-0.2.2 test/bubble_sort/ruby/bubble_sort.rb
jeka-0.2.1 test/bubble_sort/ruby/bubble_sort.rb
jeka-0.2.0 test/bubble_sort/ruby/bubble_sort.rb