xxl.mathematica.map.KeySort Maven / Gradle / Ivy
package xxl.mathematica.map;
import java.util.Comparator;
import java.util.Map;
/**
* 键排序
*/
public class KeySort {
/**
* 使用排序函数对映射进行排序
*
* @param map
* @param comparator
* @param
* @param
* @return
*/
public static , V> Map keySort(Map map, Comparator comparator) {
return io.vavr.collection.TreeMap.ofAll(comparator, map)
.toJavaMap();
}
/**
* 默认自然排序函数
*
* @param map
* @param
* @param
* @return
*/
public static , V> Map keySort(Map map) {
return keySort(map, Comparator.naturalOrder());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy