title: Is that possible to use @max in filter in Realm?
body: <p>I have an Object, say</p>
  
  <pre><code>class Task:Object {
      dynamic var id:Int = 0
      dynamic var name:String = ""
  
      override func primaryKey() -&gt; String {
          return "id"
      }
  }
  </code></pre>
  
  <p>When I use filter with max.</p>
  
  <pre><code>let tasks = realm.allObjects(ofType: Task.self)
  let results = tasks.filter(using: "id.@max")
  </code></pre>
  
  <p>I got the error:</p>
  
  <blockquote>
    <p>Unable to parse the format string "id.@max".</p>
  </blockquote>
  
  <p>Then I realized I should use </p>
  
  <pre><code>let results = tasks.filter(using: "id == id.@max")
  </code></pre>
  
  <p>Then I got another error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'Invalid predicate', reason:
    'Aggregate operations can only be used on key paths that include an
    array property'</p>
  </blockquote>
  
  <p>Now I am wondering what can I do if I want to use @max in filter?</p>
  
  <p>I know I could use <code>sorted</code> to get the task with the max id. But I want to know if I could use it with filter.</p>