We have the following function that returns the search results for an array of key passed into the query:
func getItems(ids: [String]) -> [CBLDocument] {
var documents: [CBLDocument] = CBLDocument
let query = database.viewNamed(“byCode”).createQuery()
query.keys = ids
var error: NSError?
let result = query.run(&error)
while let row = result?.nextRow() {
documents.append(row.document)
}
return documents
}
The problem is that the results are not being returned in the order of the keys in the array. Could you please advice as to how we could achieve that and maintain the order?