Java List Sort setToSortedList(final Set set, final Comparator comparator)

Here you can find the source of setToSortedList(final Set set, final Comparator comparator)

Description

Converts a Set into a sorted List.

License

Open Source License

Parameter

Parameter Description
set the set to convert.
comparator the comparator used to sort the list.

Return

the sorted list.

Declaration

public static <T> List<T> setToSortedList(final Set<T> set, final Comparator<T> comparator) 

Method Source Code


//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;
    }
}

Related

  1. quickSort(Comparable[] list, int min, int max)
  2. removeSortByColumnName(List sortProperty, List ascending, String columnName)
  3. removeSortColumns(List selectColumns, List sorts, List ascending)
  4. removeSortColumns(List selectColumns, List sorts, List ascending)
  5. searchSorted(List a, double v)
  6. sort( S list)
  7. sort(Collection list)
  8. Sort(Collection list)
  9. sort(Collection list)