I have the following (example) list:
list = {"b", "a", "b", "b", "a", "c", "c", "c", "d", "b", "aa"};
and want to distinguish its elements by appending a counter in the following manner:
ord = Ordering @ Ordering @ list;
Part[#, ord]& @ Flatten[#, 1]& @
MapIndexed[{#1, Last @ #2}&, #, {2}] & @ Gather @ Sort @ list
{{"b", 1}, {"a", 1}, {"b", 2}, {"b", 3}, {"a", 2}, {"c", 1}, {"c", 2}, {"c", 3}, {"d", 1}, {"b", 4}, {"aa", 1}}
This solution is somehow "expensive" (three ordering / sorting) operations, so the question is:
Are there more efficient alternatives?