FundingRank and SourceBucket are enums but essentially int
enum FundingRank {
LESS_THAN_0(0),
LESS_THAN_1(1),
LESS_THAN_100(100);
private final int rank;
FundingRank(int i) {
this.rank = i;
}
}
enum ScoreBucket {
MORE_THAN_1000(1000),
MORE_THAN_500(1000),
MORE_THAN_100(100),
MORE_THAN_10(10);
private final int bucket;
ScoreBucket(int i) {
this.bucket = i;
}
}
I have a TreeMap<FundingRank, TreeMap<scoreBucket, List<Kids>> > holding data like
fundingRank scoreBucket List<Kids>
0 1000 List(with 1 elements)
500 List(with 2 elements)
100 List(with 4 elements)
10 List(with 3 elements)
1 1000 List(with 4 elements)
500 List(with 7 elements)
100 List(with 4 elements)
10 List(with 3 elements)
Now I , want to find element minimum fundingRank and maximum scoreBucket with minimum 5 kids, if not then minimum fundingRank and maximum scoreBucket
myMap.entrySet().stream()
.filter(e -> e.getvalue().entryset().stream()
.filter(e2 ->e2.getvalue().size()).findfirst();
Output sorted map like this:
1 500 List(with 7 elements)
0 100 List(with 4 elements)
1 1000 List(with 4 elements)
1 100 List(with 4 elements)
0 10 List(with 3 elements)
...
So, I am trying to sort the TreeMap<Int, TreeMap<Int, List>>, the sort order is defined as MinFunding rank and max ScoreBucket (with threshold 5, if bucket has 5 kids, meaning if there is any other smaller bucket with more kids, the higher score bucket wins, or if there is a bigger FundingRank with higher bucket size and more kids, still the lower fundingBucket row wins if it meets 5 kids threshold), then pick up the 1st row hope it is clear now