%% Sort Rows of Table
% Sort the rows of a table by variable values.
% Create a table with four variables listing patient information for five people.

LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];

tblA = table(Age,Height,Weight,BloodPressure,'RowNames',LastName)

%
% Sort the rows of the table. The sortrows function sorts the rows in ascending order first by the variable Age, and then by the variable Height to break the tie between the two rows with equal ages.

tblB = sortrows(tblA)

% Copyright 2012 The MathWorks, Inc.