MATLAB: Sort categorical variables in an alphabetical order

MATLAB

I have a set of categorical variables
A = {'NY','Boston'}
How can one sort A to B as
B = {'Boston','NY'}
I tried sort but does not work.

Best Answer

As Ive Ive suggested: the sort function will do what you need:
B = categorical({'NY','Boston'});
sort(B)
ans = 1×2 categorical array
Boston NY