Skip to contents

Emulates the behavior of the sortrows function on Matlab

Usage

sortrows(A, column = 1)

Arguments

A

matrix

column

ordering column

Value

The A matrix sorted by the first row, then the second

Examples

mx <- matrix(c(3, 2, 2, 1, 1, 10, 0, pi), 4)
mx
#>      [,1]      [,2]
#> [1,]    3  1.000000
#> [2,]    2 10.000000
#> [3,]    2  0.000000
#> [4,]    1  3.141593
sortrows(mx)
#>      [,1]      [,2]
#> [1,]    1  3.141593
#> [2,]    2 10.000000
#> [3,]    2  0.000000
#> [4,]    3  1.000000