I have a Map in java that has strings for key as well as value.
Data is like following: <"Ram", "1">, <"Johny", "1">, <"Humber", "4">
I want to sort the map based on its keys. So, In the end, I will have Johny, Humber, Ram
Eventually, I am trying to get two strings out of this Map. First String: in alphabetical order and Second String: Answers (in the same order as the question).
Right now I have the following:
Iterator itr = paramMap.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry pair = (Map.Entry)itr.next();
questionAnswers += pair.getKey()+",";
}
This gets me the questions in a string but they are not in order.