Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Ernest Friedman-Hill:
Give up. HashMap won't store your data sorted in any order, let alone by value.
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Originally posted by Ernest Friedman-Hill:
LinkedHashMap, on the other hand, will store items in insertion order. So if you sort by value, as you've shown here, then insert into a LinkedHashMap in sorted order, they'll stay that way.
Disclaimer : The above is not recomended absolutely in any circumstances as overriding hashcode in the above fashion is a strict no-no.... It is not only bad programatic practise but also its usage could lead to further issues.
Originally posted by Devesh H Rao:
involves a bit of a hack
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Jesper Young:
Why do you even suggest such a solution if you already know how bad and ugly it is?
Originally posted by Ernest Friedman-Hill:
Give up. HashMap won't store your data sorted in any order, let alone by value.
Disclaimer : The above is not recomended absolutely in any circumstances as overriding hashcode in the above fashion is a strict no-no.... It is not only bad programatic practise but also its usage could lead to further issues.
Originally posted by Jesper Young:
By making hashCode() return 0, the HashMap will store all data in one bucket.
Originally posted by Ernest Friedman-Hill:
even when it is used for evil...![]()
--
Sandeep
Consider Paul's rocket mass heater. |