lets say we have a custom class named imageFile and this class contains two properties.
class imageFile { var fileName = String() var fileID = Int(
You return a sorted array from the fileID property by following way:
Swift 2
let sortedArray = images.sorted({ $0.fileID > $1.fileID })
Swift 3 OR 4
let sortedArray = images.sorted(by: { $0.fileID > $1.fileID })
Swift 5.0
let sortedArray = images.sorted { $0.fileID < $1.fileID }