merge sort algorithm solved in Scala programming language