Here you can find the source of mapToSortedSet(Map map)
public static SortedSet mapToSortedSet(Map map)
//package com.java2s; /*//w ww . j a v a 2 s . co m * Created on 02.11.2004 * * COPYRIGHT NOTICE * * Copyright (C) 2005 DFKI GmbH, Germany * Developed by Benedikt Fries, Matthias Klusch * * The code is free for non-commercial use only. * You can redistribute it and/or modify it under the terms * of the Mozilla Public License version 1.1 as * published by the Mozilla Foundation at * http://www.mozilla.org/MPL/MPL-1.1.txt */ import java.util.Iterator; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; public class Main { public static SortedSet mapToSortedSet(Map map) { SortedSet result = new TreeSet(); Iterator iter = map.entrySet().iterator(); Map.Entry me; while (iter.hasNext()) { me = (Map.Entry) iter.next(); result.add(me.getValue()); } return result; } }