I have data that is not fetched from DB.
The Data is in this format:
List of Dictionary - 2 items
What I'm trying to achieve is that I get the whole object that has the highest value for Max_days. So as returning result I should get
Can you help me, guys? Thx
Discussion posts and replies are publicly visible
Also to mention this should not be the solution for just these 2 objects as I can have a list of N objects. So the one with the highest Max_days should be returned. Thx
You can use todatasubset() to sort lists of dictionaries.
Agree with Stefan, utilize todatasubset() and sort by Max_days, return the top item only:
a!localVariables( local!data: { {id: 1, Max_days: 54, Max_amount: 36671}, {id: 2, Max_days: 1317, Max_amount: 15158}, {id: 3, Max_days: 99, Max_amount: 12545}, {id: 4, Max_days: 200, Max_amount: 54321} }, index( todatasubset(local!data,a!pagingInfo(1,-1,a!sortInfo("Max_days",false))).data, 1, null ) )
I agree with Stefan and Chris! You can even give batchSize as 1 in which case the need for indexing will also be eliminated.
Ah yes, batchSize -1 is definitely not necessary, "1" will work correctly there. I would still recommend indexing however as to return a single dictionary vs a list of dictionary with 1 item, just incase :)