%% Specify Sorting Directions for Matrix Rows
% Sort a tall matrix using several columns with different sorting directions.
% Create a 100-by-5 matrix of random integers. Convert the in-memory array into a tall array.

X = randi(10,100,5);
TX = tall(X)

%
% Sort TX using the first three columns and return the top 10 rows. Specify the sorting direction for each column. Collect the values into memory to view the compete results.

T = topkrows(TX,10,1:3,{'descend','ascend','ascend'})

%

T12 = gather(T)

% Copyright 2012 The MathWorks, Inc.