All Downloads are FREE. Search and download functionalities are using the official Maven repository.

love.cq.util.CollectionUtil Maven / Gradle / Ivy

There is a newer version: 1.5
Show newest version
package love.cq.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CollectionUtil {
	/**
	 * map 按照value排序
	 * 
	 * @return
	 */
	public static  List> sortMapByValue(HashMap map, final int sort) {
		List> orderList = new ArrayList>(map.entrySet());
		Collections.sort(orderList, new Comparator>() {
			@Override
			@SuppressWarnings("unchecked")
			public int compare(Map.Entry o1, Map.Entry o2) {
				return (((Comparable) o2.getValue()).compareTo(o1.getValue())) * sort;
			}
		});
		return orderList;
	}
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy