Paginate entries ordered by a custom date field I'm trying to paginate a bunch of events based on their start date. The order part is working correctly, but each consecutive page just loads the exact same entries. My code:

{% set events = craft.entries().section('events').limit(2).order('startDate asc') %}
{% paginate events as pageInfo, pageEntries %}

{% for event in events %}
    // Event content
{% endfor %}

{% if pageInfo.prevUrl %}&lt;a href="{{ pageInfo.prevUrl }}"&gt;Previous Page&lt;/a&gt;{% endif %}
{% if pageInfo.nextUrl %}&lt;a href="{{ pageInfo.nextUrl }}"&gt;Next Page&lt;/a&gt;{% endif %}


What am I missing?
Pulling it all inside paginate fixed it:

{% paginate craft.entries().section('events').limit(2).order('startDate asc') as events %}

{% for event in events %}
    // Event content
{% endfor %}

{% if paginate.prevUrl %}&lt;a href="{{ paginate.prevUrl }}"&gt;Previous Page&lt;/a&gt;{% endif %}
{% if paginate.nextUrl %}&lt;a href="{{ paginate.nextUrl }}"&gt;Next Page&lt;/a&gt;{% endif %}