I have a Map with key String and values String and a list of Strings. i want to sort the Map with keys based on the order of values present in the list.
package da.fa;
public class MapSorted {
public static void main(String[] args) {
List<String> efgh = new ArrayList<String>();
efgh.add("ccc");
efgh.add("aaa");
efgh.add("ddd");
efgh.add("aaa");
Map<String, String> abcd = new HashMap<String, String>();
abcd.put("aaa", "1111");
abcd.put("bbb", "1111");
abcd.put("ccc", "1111");
abcd.put("ddd", "1111");
abcd.put("eee", "1111");
}
}
in this, abcd should be sorted by the order of what values are in the list efgh has.