I am new to Scala and was trying the Selection Sort algorithm. I managed to do a min sort but when I try to do the max sort I get a sorted array but in decreasing order. My code is:
def maxSort(a:Array[Double]):Unit = {
    for(i <- 0 until a.length-1){
            var min = i
                    for(j <- i + 1 until a.length){
                            if (a(j) < a(min)) min = j
            }
    val tmp = a(i)
    a(i) = a(min)
    a(min) = tmp
    }
}
I know that I have to append my result at the end of the array, but how do I do that?
 
     
    