lets say we have a custom class named imageFile and this class contains two properties.
class imageFile { var fileName = String() var fileID = Int(
I do it like this and it works:
var images = [imageFile]() images.sorted(by: {$0.fileID.compare($1.fileID) == .orderedAscending })