# Implementation Bubble Sort

def bubbleSort(itens)
    n = itens.length

    for i in (1..n)
        
        for j in (0..(n-i-1))
            
            if itens[j] > itens[j+1]
                #Troca de elementos na posição j e j+1
                itens[j], itens[j+1] = itens[j+1], itens[j]
            end
        end
    end
end

#Array
puts "unordered array:"
puts itens = Array[64, 34, 25, 12, 22, 11, 90]

#function
bubbleSort(itens)

puts "Sorted array is:"
itens.each do |item|
    puts "#{item}"
end  