sort fetched passwords by name

This commit is contained in:
Bob Sun 2017-01-23 17:49:06 +08:00
parent a4b26b3bd3
commit cb333e7bfb
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -121,7 +121,9 @@ class PasswordStore {
let passwordEntityFetch = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
do {
let fetchedPasswordEntities = try context.fetch(passwordEntityFetch) as! [PasswordEntity]
return fetchedPasswordEntities
return fetchedPasswordEntities.sorted(by: { (p1, p2) -> Bool in
return p1.name! < p2.name!;
})
} catch {
fatalError("Failed to fetch employees: \(error)")
}