MATLAB: How to create a Matrix which shows a ranking of values

ranking

Hey guys,
sorry for this bad title but i didnt know how to express this differently.
I currently have a vector of 19 names (e.g. Lisa, Paul, Franz, Lisa,…). Some names appear more often than one time. From this vector I Need a Code that gives me a table. One column of this table should show how many times a Name appears and in the other row you can see the Name. This table should be in a descending order.
It should look like:
Count (Column 1) II Name (Column 2)
  • 7 II Lisa
  • 4 II Paul
  • 2 II Michael
Can anyone of you help me to write this Code? Would really appreciate your help 🙂
Best Florian

Best Answer

Here is one way:
% Name list
names = {'Jim','Bob','Bob','Joe','Lisa','Lisa','Joe','Lisa'};
% Tabulate
tbl = tabulate(names);
% Sort
[~,sortingIndex] = sort([tbl{:,2}],'descend');
tbl = tbl(sortingIndex,:)