Skip to content
Advertisement

How to get object field for max value in another field in grouped by one more field?

I have list of entities that looks like this:

JavaScript

For each code with max version I wanna to get creationDate. I did it like this, but I think that it can be done somehow easier…

JavaScript

Advertisement

Answer

You can do like this:

After grouping by each code then use collectingAndThen collectors and find max item based on version amount and at the end use map to extract creationCode.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement