### MxSortRows - sort the rows of the matrix

Matrix functions
(AmiBroker 6.10)

 SYNTAX MxSortRows( mx, ascending = True, col1 = 0, col2 = -1, col3 = -1 ) RETURNS Matrix FUNCTION Sorts the rows of the matrix in ascending/descending order of the col1 column. When the col1 column has equal values, SortRows sorts according to the col2 and col3 columns in succession (if col2 and col3 are specified and >= 0 ).Column numbers are zero based. Hint: if you want to sort columns instead you can Transpose/Sort rows/Transpose back. EXAMPLE ```m = MxFromString("[ 9, 1, 6; 40, 30, 20; 8, 7, 3; 3, 5, 1 ]"); printf("Input matrix "); printf( MxToString( m ) + " " ); printf("Rows %g, Cols %g ", MxGetSize( m, 0 ), MxGetSize( m, 1 ) ); printf("Sorting every row separately "); m2 = MxSort( m, 0 ) ; printf( MxToString( m2 ) + " " ); printf("Sorting every column separately "); m3 = MxSort( m, 1 ) ; printf( MxToString( m3 )+ " "); printf("Sorting rows by contents of first column "); m4 = MxSortRows( m, True, 0 ) ; printf(MxToString( m4 )+ " "); printf("Sorting rows by contents of second column "); m5 = MxSortRows( m, True, 1 ) ; printf(MxToString( m5 )+ " ");``` SEE ALSO Matrix() function , MxTranspose() function

#### References:

The MxSortRows function is used in the following formulas in AFL on-line library: