How can I reverse the order of this list in from Firebase? I want the last item to be the first. I tried to use queryOrdered
, but that did not make a difference
As @Frank says, you need to sort your results client-side.
You can either sort the array with something like this
let sorted = self.RquestInfoArray.sorted(by: { (r1: RequestInfoType, r2: RequestInfoType) -> Bool in
return r1.dateAmount > r2.dateAmount
})
but if you really just want to reverse the array, probably simpler just to add your new elements at the start instead of the end
self.RquestInfoArray.insert(contentsOf: array, at: 0)