Class MapHelper


  • public class MapHelper
    extends Object
    • Method Detail

      • sortByValue

        public static <K,​V extends Comparable<? super V>> Map<K,​V> sortByValue​(Map<K,​V> map)
      • sortByValue

        public static <K,​V extends Comparable<? super V>> Map<K,​V> sortByValue​(Map<K,​V> map,
                                                                                           boolean ascending)
        sort map on value
        Type Parameters:
        K -
        V -
        Parameters:
        map -
        ascending -
        Returns:
        a ordered map sorted on value
      • sameSorting

        public static <K,​V extends Comparable<? super V>> Map<K,​V> sameSorting​(Map<K,​V> map,
                                                                                           Map<K,​V> reference)
        sort map with the same sorting than other map and remove key not found in reference.
        Type Parameters:
        K -
        V -
        Parameters:
        map - map to sort
        reference - ordered map with key order reference
        Returns:
        new ordered map with same order than reference
      • sameSortingNormilized

        public static <V extends Comparable<? super V>> Map<String,​V> sameSortingNormilized​(Map<String,​V> map,
                                                                                                  Map<String,​V> reference)
        sort map with the same sorting than other map and remove key not found in reference.
        Type Parameters:
        String -
        V -
        Parameters:
        map - map to sort
        reference - ordered map with key order reference
        Returns:
        new ordered map with same order than reference
      • main

        public static void main​(String[] args)