# mat.sort: Sort a Matrix According to a Specified Column In BioPhysConnectoR: BioPhysConnectoR

## Description

Sorts a matrix in respect to one or more specified columns by preserving its row context. If more than one columns is given the function uses the columns in the specified order for sorting.

## Usage

 `1` ```mat.sort(mat, sort, decreasing = FALSE) ```

## Arguments

 `mat` matrix to be sorted `sort` column indices `decreasing` logical, if TRUE the column is ordered decreasingly

## Value

Returns the sorted matrix.

## Author(s)

Franziska Hoffgaard

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```mat<-matrix(data = as.integer(runif(16, 1, 20)), nrow = 4) #Sort the matrix in respect to the second column of mat m<-mat.sort(mat, 2) #Sorting mat according to more than one column mat<-matrix(data = c(rep(3, 3), as.integer(runif(13, 1, 20))), nrow = 4) m1<-mat.sort(mat, c(1, 2)) m2<-mat.sort(mat, c(2, 1)) ```

### Example output

```Loading required package: snow
Loading required package: matrixcalc
```

BioPhysConnectoR documentation built on May 30, 2017, 6:46 a.m.