package com.xing.listfile
/**
* Created by DengNi on 2017/2/23.
*/
object OrderBubbleSort extends App {
val sortArray = Array(49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51)
for( j <- 0 until( sortArray.length -1)){ // 循环完成一次外循环后 就会得到 一次最大值 ,最大值将不再参与排序
for(i<- 0 until sortArray.length - 1 -j ){// 对每个外循环和进行多次内循环
if(sortArray(i) > sortArray(i+1)){
val temp = sortArray(i)
sortArray(i) = sortArray(i+1)
sortArray(i+1) = temp
}
sortArray.foreach(x=> print(x + " "))
println()
}
}
}