Sorting the Symbols according to closing price

I am able to fetch details about the closing prices using API.
But i am not able to understand how to use the

After fetching all details, you can simply store the relevant details inside an object of TotalReturnsDto type. You can study the object, see what’s it storing and filter out relevant details from the API return to store in that object.

I am trying to use ArrayList of dtoname.
I am getting no error but i am not able to use the getsymbol and the second function

That looks like a java specific issue. There is also the option of using HashMap though, but it’ll be more difficult. I learned that the hard way.

I tried to use the hash map approach but sorting part seem way too complicated.

Exactly. Its a really really long function. I did manage to implement it though. But its not worth the effort.

So what else should i use?
I am not getting the part where i have to filter the information into totalreturnsdto

I actually did it using HashMap and it worked. I’ll try doing it with TotalReturnsDto now and see what works.

Please update me as soon as possible

Just did using a TotalReturnsDto class object. Had no issues really. Just made a list of that type, and kept adding the symbol and closing price. Sorted it using a modified comparator added in TotalReturnsDto class. Way much easier than the HashMap approach.

So wee need to add comparator in totalreturnsdto class?
And I need to use the parametrised constructor to add values?

Yes, as there is a link for same in the milestone as well, which explains other methods for sorting ArrayLists as well. I used comparator because I was able to grasp it easily.

There is already a parametrised constructor in that class. Just use that only.

Rather than modifying the DTO class code, you can pass a comparator or a lambda function into the Collections.sort() method as well.