I want to be able to sort the below HashMap by key, I have tried code like the following:
SortedSet<String> keys = new TreeSet<String>(HashMap.keySet());
for (String key : keys) {
// String value = map.get(key);
// do something
}
But this brings back the error:
Cannot make a static reference to the non-static method keySet() from the type HashMap
If someone could point me in the right direction, that would be great, thanks!
The HashMap and it's key's:
ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
// XML node keys
static final String KEY_ITEM = "item"; // parent node
static final String KEY_ID = "id";
static final String KEY_NAME = "name";
static final String KEY_TITLE = "title";
static final String KEY_COST = "cost";
static final String KEY_DESC = "description";
static final String KEY_LINK = "link";
static final String KEY_PUBDATE = "pubDate";