I'm trying to sort my HasMap ArrayList so my listview is sorted by values but I'm not getting it.
Basically I have several keys and one of them is "type" which holds values like "1", "4", "3",....
I want to order the list by this key "type" but I'm getting "1", "11", "2" instead of "1", "2", "11"...
I'm trying this code to sort it:
Collections.sort(myList, new Comparator<HashMap<String, String>>() {
public int compare(HashMap<String,
String> mapping1,HashMap<String, String> mapping2) {
return mapping1.get("type").compareTo(mapping2.get("type"));
}
});
Stringfor the key, when you're using it purely to storeints?