ruby冒泡排序

class BubbleSorting
  array=[8,12,3,1,2,5,9,6,3,4,5,6,4,3,8] 

  for i in (0..array.length)
    for j in (1..array.length-1)
      unless array[j]<array[j-1]
      (array[j],array[j-1]=array[j-1],array[j]) 
      end
    end
  end

  print array.join(",")
end

你可能感兴趣的:(J#,Ruby)