I need to sort a array
alphabetically in swift
.
I found this code:
var images : [imageFile] = []
images.sort({ $0.fileID > $1.fileID })
But I do not know how I can apply it to my array
My code:
if let dataFromString = datosJson.data(using: String.Encoding.utf8, allowLossyConversion: false) {
let json = JSON(data: dataFromString)
for (index, subJson):(String, JSON) in json {
for a in 0 ..< subJson.count {
self.currentlyConstructingObjeto = Objeto()
self.currentlyConstructingObjeto.nombre = subJson[a]["nombre"].stringValue
self.currentlyConstructingObjeto.tipo = subJson[a]["tipo"].stringValue
self.currentlyConstructingObjeto.id = subJson[a]["id"].stringValue
self.objetos.append(self.currentlyConstructingObjeto)
}
}
}
The array that I have to sort is self.objetos