Java examples for java.util:List Creation
Returns an alphabetically sorted list of the keys.
//package com.java2s; import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; public class Main { /** Returns an alphabetically sorted list of the keys. */ public static Vector getSortedKeyList(Hashtable hashtable) { Vector result = new Vector(); Enumeration keys = hashtable.keys(); while (keys.hasMoreElements()) { result.add(keys.nextElement()); }/* w w w .jav a 2 s .c o m*/ Collections.sort(result, new Comparator() { public int compare(Object a, Object b) { String textA = a.toString(); String textB = b.toString(); return textA.compareToIgnoreCase(textB); } }); return result; } }