martedì 10 novembre 2009

Sorted HashMap


public HashMap getSortedMap(HashMap hmap)
{
HashMap map = new LinkedHashMap();
List mapKeys = new ArrayList(hmap.keySet());
List mapValues = new ArrayList(hmap.values());
hmap.clear();
TreeSet sortedSet = new TreeSet(mapValues);
Object[] sortedArray = sortedSet.toArray();
int size = sortedArray.length;
// a) Ascending sort

for (int i=0; i

in riferimento a: Collections: Lists, Sets, and Maps - how to sort a hashmap using its key? [Locked] (visualizza su Google Sidewiki)

Nessun commento:

Posta un commento