     }
 
     private func persistAccountOrder() {
-        let persistentRefs = accounts.map { $0.persistentRef! }
-        userDefaults.set(persistentRefs, forKey: persistentRefsKey)
+        let sortedPersistentRefs = accounts.map { $0.persistentRef! }
+        userDefaults.set(sortedPersistentRefs, forKey: accountOrderKey)
     }
 
     private func updateEditing() {

        }

        accounts = keychain.accounts
        let persistentRefs = userDefaults.array(forKey: persistentRefsKey) as? [Data] ?? []
        accounts.sort { a, b in
            let aIndex = persistentRefs.index(of: a.persistentRef! as Data) ?? 0
            let bIndex = persistentRefs.index(of: b.persistentRef! as Data) ?? 0
            return aIndex < bIndex
        }
        persistAccountOrder()

import UIKit

private let accountOrderKey = "persistentRefs"
private let accountSearchResultsViewControllerIdentifier = "AccountSearchResultsViewController"
private let accountCellIdentifier = "AccountCell"
private let scanSegueIdentifier = "ScanSegue"
