%% Sort Rows of Tall Table
% Sort rows of heterogeneous data in a tall table.
% Create a tall table for the airlinesmall.csv data set. Select the Year, Month, and UniqueCarrier variables as the variables of interest.

ds = datastore('airlinesmall.csv','SelectedVariableNames',...
    {'Year','Month','UniqueCarrier'});
tt = tall(ds)

%
% Sort the table rows in descending order and return the top 15 rows. Collect the values into memory to view the results.

T = topkrows(tt,15)

%

top15 = gather(T)

%
% Sort the table rows using an alphabetical sort of the UniqueCarrier variable.

T2 = topkrows(tt,10,'UniqueCarrier','ascend')

%

top10 = gather(T2)

% Copyright 2012 The MathWorks, Inc.