Alphabetically sort ArrayList<String> or HashMap<String, x>?

Hi,

Is there a way to sort an ArrayList<String> or a HashMap<String, x> built into those classes? I can do it myself manually, but was wondering if anything exists to do it for you. For example, in C++, a map<string, x> automatically sorts itself alphabetically.

Thanks
DJ_AM_JuiceboxAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CPColinConnect With a Mentor Senior Java ArchitectCommented:
java.util.Collections.sort() takes a List as its parameter and sorts it in-place.

java.util.TreeMap implements SortedMap (and Map, like HashMap), and keeps its keys in sorted order.
0
All Courses

From novice to tech pro — start learning today.