ios - Get the array with the largest object inside an array of an array -


i have array of array of cllocations , trying find array has cllocation object happened according timestamp. either index or actual list sufficient.

so far have come with:

let latestlist = listoflistoflocations.index{$0.max{a,b in a.timestamp < b.timestamp} < $1.max{c,d in c.timestamp < d.timestamp}} 

but i'm getting no luck , can't head round being relatively new swift. appreciated.

first "submaxes" of each array, , take max of obtain global maximum.

let subarraycontainingmostrecentobject = listoflistoflocations     .flatmap{ subarray in         return subarray             .max{ $0.timestamp < $1.timestamp }             .map{ submax in (subarray: subarray, submax: submax) }     }     .max{ $0.submax.timestamp < $1.submax.timestamp }?.subarray 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -