Im using hashmap and arraylist... How to sort the arraylist ? eg) In hashmap values are in order like one,two,three,four,five but i stored these values in arraylist the order changed like three,one,five,two,four
In my code groupList,gnamelist and newList are all arraylist... In print sts PLACES are in correct order but while print on NEWLIST PLACES the order changed How to sort this in order?
My code
HashMap<String, String> map = new HashMap<String, String>(); // adding each child node to HashMap key => value map.put(TAG_PLACE, gname); map.put(TAG_HOTEL,lname); // adding HashList to ArrayList groupList.add(map); gnamelist.add(gname); System.out.println("PLACES" + gnamelist); List<String> newList = new ArrayList<String>(new LinkedHashSet<String>(gnamelist)); Collections.sort(newList,Collections.reverseOrder()); System.out.println("NEWLIST PLACES" + newList);