Here you can find the source of setToSortedList(final Set
Set
into a sorted List
.
Parameter | Description |
---|---|
set | the set to convert. |
comparator | the comparator used to sort the list. |
public static <T> List<T> setToSortedList(final Set<T> set, final Comparator<T> comparator)
//package com.java2s; import java.util.*; public class Main { /**//ww w . j ava2 s .c o m * Converts a <code>Set</code> into a sorted <code>List</code>. * * @param set the set to convert. * @param comparator the comparator used to sort the list. * @return the sorted list. */ public static <T> List<T> setToSortedList(final Set<T> set, final Comparator<T> comparator) { final List<T> list = new LinkedList<T>(set); Collections.sort(list, comparator); return list; } }