title: Sort by date - Swift 3
body: <p>I have a func getData() which retrieves core data entity, and I want to sort them by date. How can I apply NSPredicate or Predicate to get the data from CoreData sorted by date?</p>
  <p>My core data entity:
  Entity: Expenses
  Attributes:</p>
  <ul>
  <li><p>amount</p>
  </li>
  <li><p>category</p>
  </li>
  <li><p>date</p>
  <p>func getData() {
  let context = appDelegate.persistentContainer.viewContext</p>
  <pre><code>  do {
        expenses = try context.fetch(Expenses.fetchRequest())
    } catch {
        print(&quot;Cannot fetch Expenses&quot;)
    }
  </code></pre>
  <p>}</p>
  </li>
  </ul>