lets say we have a custom class named imageFile and this class contains two properties.
class imageFile { var fileName = String() var fileID = Int(
You can also do something like
images = sorted(images) {$0.fileID > $1.fileID}
so your images array will be stored as sorted