%% Specify Sorting Directions for Matrix Columns
% Sort a matrix using several columns with different sorting directions.
%
% Create a 100-by-5 matrix of random integers between 1 and 10.

rng default % for reproducibility
X = randi(10,100,5);

%
% Sort X using the first three columns and return the top 10 rows. Specify a sorting direction for each column using a cell array.

TA = topkrows(X,10,1:3,{'descend','ascend','ascend'})

% Copyright 2012 The MathWorks, Inc.