java - Sort Map By Value Object Member -
this question has answer here:
- sort map<key, value> values (java) 44 answers
i have generic map defined thus
map<integer, book> bookcollection
the integer book id , book book object. book object has member called publicationyear.
how sort map book objects in order book's publicationyear member. so, if iterate through sorted map, oldest book appears first newest book.
at moment, map randomly sorted.
the publicationyear has part of key. sort based on that.
Comments
Post a Comment