Hi David,
thanks for prompt reply and sorry for my late reply :).
I think I sorted it out creating a function which converts the DenseMatrix to a List of DenseVector, sorts the DenseVectors and then it re-converts the List of DenseVectors back to a DenseMatrix.
The code snippet is below, i still need to test it properly though (just run a quick test as of today).
I am new with scala, so I am not sure if this is the best way.
object sortDenseMatrix {
def apply(inputMatrix: DenseMatrix[Double], colIndex: Int): DenseMatrix[Double] = {
val sortingList: List[DenseVector[Double]] = (0 until inputMatrix.rows).map(i => inputMatrix(i,::).t).toList.sortBy {x => x(0)}
val outputMatrix = DenseMatrix(sortingList.map(_.toArray):_*)
return outputMatrix
}
}
Davide