Here you can find the source of sortKeys(final Set
public static List<String> sortKeys(final Set<String> keySet)
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; public class Main { public static List<String> sortKeys(final Set<String> keySet) { List<String> keys = new ArrayList<String>(); for (String key : keySet) { keys.add(key);/*from www . j a v a 2 s .c om*/ } Collections.sort(keys); return keys; } }