title: sort coreData fetch (swift4)
body: <p>Right now my code is using NSPredicate or sort descriptor to basically just collect a name. I would like NSPredicate to sort all of the names from a-z thats it. </p>
  
  <p>COREDATAHANDLER</p>
  
  <pre><code>class coreDataHandler: NSObject {
  
  private class func getContext() -&gt; NSManagedObjectContext{
  
      let appDelegate = UIApplication.shared.delegate as! AppDelegate
      return appDelegate.persistentContainer.viewContext
  }
  class func saveObject(username:String, password:String) -&gt; Bool{
   let context = getContext()
      let entity = NSEntityDescription.entity(forEntityName: "User", in: context)
      let managedObject = NSManagedObject(entity: entity!, insertInto: context)
  
      managedObject.setValue(username, forKey: "username")
    managedObject.setValue(password, forKey: "password")
      do {
          try context.save()
          return true
      } catch {
          return false}
  
  
  
      }
   class func filterData() -&gt; [User]? {
      let conttext = getContext()
      let fetchRequest:NSFetchRequest&lt;User&gt; = User.fetchRequest()
  
      var user:[User]? = nil
  
      var predicate = NSPredicate(format: "username contains[d] %@" ,"duke")
  
      fetchRequest.predicate = predicate
      do {
          user = try conttext.fetch(fetchRequest)
          return user
      }catch {
          return user
      }
  }
  </code></pre>
  
  <p>VIEWCONTROLLER</p>
  
  <pre><code>  user = coreDataHandler.filterData()
      for i in user! {
          print("Judou : \(i.username!)")
      }
  </code></pre>