Skip to content

Commit b06c996

Browse files
authored
Update Sorts.scala
1 parent 182dee6 commit b06c996

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scala/11_sorts/Sorts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.util.control.Breaks._
22
object Sorts {
33
def main(args: Array[String]): Unit ={
4-
println(bubbleSort(Array(0, 1, 2, 3, 4, 5, 6, 7)).mkString(", "))
4+
println(bubbleSort(Array(0, 3, 7, 6, 4, 5, 1, 2)).mkString(", "))
55
}
66

77
def bubbleSort(arr: Array[Int]): Array[Int] = {
@@ -10,7 +10,7 @@ object Sorts {
1010
for(i <- (l-1) to (1, -1)){
1111
var flag = false
1212
for(j <- 0 until i){
13-
if(arr(j) < arr(j+1)){
13+
if(arr(j) > arr(j+1)){
1414
val tmp = arr(j)
1515
arr(j) = arr(j+1)
1616
arr(j+1) = tmp

0 commit comments

Comments
 (0)