Java List Sort sortEntrySetToList(Set> set)

Here you can find the source of sortEntrySetToList(Set> set)

Description

sort Entry Set To List

License

Apache License

Declaration

public static List<Entry<Long, Long>> sortEntrySetToList(Set<Entry<Long, Long>> set) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collections;
import java.util.Comparator;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class Main {

    public static List<Entry<Long, Long>> sortEntrySetToList(Set<Entry<Long, Long>> set) {
        List<Entry<Long, Long>> list = new LinkedList<Map.Entry<Long, Long>>(set);
        Collections.sort(list, new Comparator<Entry<Long, Long>>() {

            @Override// ww w.j  av a2  s .c o  m
            public int compare(Entry<Long, Long> o1, Entry<Long, Long> o2) {
                if (o1.getValue() > o2.getValue())
                    return 1;
                if (o1.getValue() < o2.getValue())
                    return -1;
                return 0;
            }
        });
        return list;
    }
}

Related

  1. sortedArray(List list)
  2. sortedInsert(List list, E e, Comparator c)
  3. sortedInsert(List list, T item, Comparator comparator)
  4. sortedList(List list)
  5. sortedUnion(List args1, List args2)
  6. sortIds(List ids)
  7. sortIfUnsorted(List genomes)
  8. sortInputQueryKeys(List l)
  9. sortItems(List items, String putOnTop)

  10. HOME | Copyright © www.java2s.com 2016