MATLAB: Sort table by two columns using column name

column namesmultiplesorttable

Hello!
I can sort a table with: sortrows(tableName, 'columnName1').
I can also sort the same table by 2 columns using: sortrows(tableName,[columnNumber1 columnNumber2])
How can I sort the table by 2 columns using column name?
The following does not work: sortrows(tableName, ['columnName1' 'columnName2']). I get an error saying "unrecognized variable name 'columnName1ColumnName2'.
Thanks in advance!

Best Answer

Use curly braces. From the doc page for sortrows
sortrows(tblA,{'Height','Weight'})
Use square brackets if you want to use indexing to specify the columns
sortrows(tblA,[1 4])