Sup. I'm trying to sort an array of the contents of the iOS documents folder in the form of URLs by their creation date in descending order. I've found many posts about sorting, but I'm not understanding them. I don't want to simply copy and paste, and BOOM! It works. I want to read and understand it. Any help is much appreciated.
Solved. In the end, I had to move the URLs from ArrayA, to a DictionaryA styled as [URL : Date], and sort it acording to date which returns ArrayB of DictionariesA keys and values. From there, I simply append each Key to ArrayC and remove the first item from ArrayB. Simple:)
for urls in unsortedVideoURLS{
videoDictionary[urls] = try! (urls.resourceValues(forKeys: keys)).creationDate!
}
var sortedDictionary = videoDictionary.sorted(by: {$0.1 > $1.1})
for _ in sortedDictionary{
videoURLS.append(sortedDictionary.first!.key)
sortedDictionary.removeFirst()
}