I have an array of dictionaries like this:
var uidTimestampsNotSorted = [[String: Timestamp]]()
and I want to sort the dictionaries by the value of the dictionary Timestamp
, how can I achieve that?
I have an array of dictionaries like this:
var uidTimestampsNotSorted = [[String: Timestamp]]()
and I want to sort the dictionaries by the value of the dictionary Timestamp
, how can I achieve that?
If you mean you want to sort the timestamps themselves, then something like this example might do it:
let dicts: [[String: Int]] = [
["a":1, "b": 2, "c": 3],
["A":10, "B": 20, "C": 30],
["AA":100, "BB": 200, "CC": 300],
]
let vs = dicts.flatMap(\.values).sorted(by: >)
With an appropriate sorting function