How to get certain object based on Max value.

I have data that is not fetched from DB. 

The Data is in this format: 

List of Dictionary - 2 items

    • Dictionary
        • id - 1(Number (Integer))
          • Max_days - 54 (Number (Integer))
            • Max_amount - 36671(Number (Integer))
            • Dictionary
                • id - (Number (Integer))
                  • Max_days - 1317 (Number (Integer))
                    • Max_amount - 15158 (Number (Integer))

                  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 

                  • Dictionary
                      • id - (Number (Integer))
                        • Max_days - 1317 (Number (Integer))
                          • Max_amount - 15158 (Number (Integer))

                        Can you help me, guys? Thx

                          Discussion posts and replies are publicly visible

                        Parents Reply
                        • 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
                            )
                          )

                        Children