MxSort
- sorts the matrix

Matrix functions
(AmiBroker 6.10)


SYNTAX MxSort( mx, dim = -1, ascening = True )
RETURNS Matrix
FUNCTION Sorts all items in a matrix

When dim == -1 (the default) it would sort:

  • a row if there is only one row (vector is horizontal)
  • a column if there is only one column (vector is vertical)
  • each column separately if there are more rows and columns than one (so we have actual 2D matrix).
When dim == 0 the function sorts the items in each row separately
When dim == 1 the function sorts the items in each column separately
EXAMPLE m = MxFromString("[ 9, 5, 6; 8, 7, 3 ]");

printf( MxToString( m ) + " " );

printf("%g, %g ", MxGetSize( m, 0 ), MxGetSize( m, 1 ) );

m2 = MxSort( m, 0 ) ;

printf( MxToString( m2 ) + " " );

m3 = MxSort( m, 1 ) ;

printf( MxToString( m3 ) + " " );
SEE ALSO Matrix() function , MxSortRows() function , MxTranspose() function

References:

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

More information:

See updated/extended version on-line.