It does seem like you should conceptually have a list of "buckets". One bucket per unique initial. Your input has initials {P, A, B}. Furthermore, the buckets should be ordered according to the initials {A, B, P}.
Each new value (a word) is added to appropriate bucket, and within the bucket they maintain the order of insertion (each bucket has a list of words).
It is probably more logical to insert new buckets in order, so that the list of buckets is always sorted.
With such data structure it is easy to iterate over the buckets (i.e. sorted), and within each bucket show items in reverse order.
If you want to do that with lists, then you do need a second list type. A list of Buckets. Perhaps with:
1 2 3 4 5 6
|
struct Bucket {
const char initial;
List list;
Bucket * next;
// other code
};
|
Note that reversing a list and simply showing the elements of a list in reverse are different.
The first changes the list and shows nothing.
The second does not change the list, but shows the elements.