sort_matrix function

Sort all columns of matrix x with respect to the j-th column.

Sort all columns of matrix x with respect to the j-th column.

This function can use the sort.list function in R. The reason for using it is that one wants the sort to carry along all columns.

sort_matrix(x, j)

Arguments

  • x: An input matrix with several columns
  • j: The column number with reference to which one wants to sort

Returns

A sorted matrix

Examples

set.seed(30) x=matrix(sample(1:50),ncol=5) y=sort_matrix(x,3);y
  • Maintainer: H. D. Vinod
  • License: GPL (>= 2)
  • Last published: 2023-10-09

Useful links