Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sortrows

Sort Rows of a Matrix (Matlab Style)


Description

Sort rows of a matrix according to values in a column.

Usage

sortrows(A, k = 1)

Arguments

A

numeric matrix.

k

number of column to sort the matrix accordingly.

Details

sortrows(A, k) sorts the rows of the matrix A such that column k is increasingly sorted.

Value

Returns the sorted matrix.

See Also

Examples

A <- magic(5)
sortrows(A)
sortrows(A, k = 2)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.