java - How to sort a hashmap whose keys are models? -


i have hashmap example

map<emailcategorymodel, list<emailblogdetailsmodel>> map; 

how sort map based on property of key?

use treemap sorted map , use comparator or comparable interface. code:

// use treemap  treemap<emailcategorymodel, emailblogdetailsmodel> map = new treemap<>(new comparatornew());  // , create comparator class comparatornew implements comparator<emailcategorymodel> {      @override     public int compare(emailcategorymodel o1, emailcategorymodel o2) {         // sorting based on model attribute here.         return 0;     }  } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -