title: CloudKit Data Sort Issues
body: <p>Not sure what I did wrong with this code but the sort on the data pull is not working with any of the data variables. I need to sort by name but right now it is sorted randomly.</p>
  <pre><code>func getStates(completionQueue: DispatchQueue = .main, completionHandler: @escaping (Result&lt;[StateList], Error&gt;) -&gt; Void) {
      
      var fetchedStates: [StateList] = []
      
      let predicate = NSPredicate(value: true)
      let sort = NSSortDescriptor(key: &quot;name&quot;, ascending: true)
      
      let query = CKQuery(recordType: &quot;StateList&quot;, predicate: predicate)
      let queryOperation = CKQueryOperation(query: query)
      query.sortDescriptors = [sort]
      
      
      queryOperation.recordMatchedBlock = { (recordID, recordResult) in
          if let record = try? recordResult.get() as CKRecord {
              var stateList = StateList(recordID: record.recordID)
              stateList.recordID = record.recordID
              stateList.id = record[&quot;id&quot;] as? String ?? &quot;&quot;
              stateList.name = record[&quot;name&quot;] as? String ?? &quot;&quot;
              stateList.initial = record[&quot;initial&quot;] as? String ?? &quot;&quot;
              
              fetchedStates.append(stateList)
              print(record.recordID)
          }
          print(&quot;recordMatchedBlock&quot;)
      }
      
      queryOperation.queryResultBlock = { result in
          DispatchQueue.main.async {
              switch result {
              case .success:
                  completionHandler(.success(fetchedStates))
              case .failure(let error):
                  completionHandler(.failure(error))
              }
          }
      }
      
      database.add(queryOperation)
  }
  </code></pre>