title: How do I paginate a sorted index in Fauna DB?
body: <p>I've created an index to sort blog posts by a date. However, when I try to paginate the results, it keeps returning the initial results.</p>
  <p>Here's my index:</p>
  <pre><code>CreateIndex({
    name: &quot;posts_desc&quot;,
    unique: false,
    serialized: true,
    source: Collection(&quot;posts&quot;),
    terms: [],
    values: [
      {
        field: [&quot;data&quot;, &quot;sort_date&quot;],
        reverse: true
      },
      {
        field: [&quot;ref&quot;]
      }
    ]
  }
  </code></pre>
  <p>Then I map out results to get each document by the ref.</p>
  <pre><code>Map(
    Paginate(Match(Index(&quot;posts_desc&quot;)), {
      after: [Ref(Collection(&quot;posts&quot;), &quot;Ref ID for 6th Document&quot;)],
      size: 5
    }),
    Lambda([&quot;date&quot;, &quot;ref&quot;], Get(Var(&quot;ref&quot;)))
  )
  </code></pre>
  <p>After running this whether in my code or via the Fauna shell, I still get the first 5 results.  I had all this working with the original index (all_posts) but now it doesn't seem to be working.  Also, the <code>after</code> object that's returned now has my sort_date value in the first position of the array and the ref in the second position.  I tried moving the ref to the first position in my index, but that broke the sorting.  Any help appreciated.</p>