object BubbleSort { def bubble(v:Array[Int]): Unit = { var t = 0 def iter = (x:Array[Int]) => { for(i <- 0 until x.length) println(x(i)) } println("**before**") iter(v) for(i <- 0 until v.size) { for(j <- i until v.size - 1) { if(v(i) >= v(j)) { t = v(i) v(i) = v(j) v(j) = t } } } println("**after**") iter(v) } def main(args:Array[String]): Unit = { var v = Array(32,25,40,10,38,50) bubble(v) } }