I have a list (List A in image) of Cases. Each case record has a field 'External Id'. I have to create a separate List such that, for all cases which has the same F-ID's, it should take the case record whose created date is the latest.
For Example L1, L2 and L3 have the same F-ID. Out of these three, L3 has the created date value which is the latest and subsequently added to the List B. Like wise should be done for the entire List A.
How can I achieve this in Apex? Is it feasible to use nested Lists to separate the case records, compare the date and add to a new list? Can't think of way to start with..