Hash maps are not ordered by definition.

You can copy the contents into an array or ArrayList, and sort that using Collection.sort().

But copying the data back into a hash table will make it unordered again.

You can also use a SortedMap, such as TreeMap, which maintains key ordering.

http://developer.android.com/reference/java/util/SortedMap.html

As a side note, it's probably overkill just to be able to use SimpleAdapter. I'd recommend you implement your own BaseAdapter subclass so you can show multiple data items for each element.

-- Kostya

01.02.2011 22:30, Mystique пишет:
Hi,

I know I can use Collections.sort() to sort an ArrayList.

But if I have HashMap, how do I do it? Possible to throw it into a
temp ArrayList to sort it?

ArrayList<HashMap<String,String>>  mylist =  new
ArrayList<HashMap<String,String>>();

How do I sort this mylist?



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to