# Pagination breaks sorting order

**URL:** <https://community.hubspot.com/t/pagination-breaks-sorting-order/103929>\
**Category:** CMS Development\
**Created:** [April 2, 2024, 5:07pm UTC](https://community.hubspot.com/t/pagination-breaks-sorting-order/103929 "2024-04-02T17:07:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PWinata](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@PWinata](https://community.hubspot.com/u/PWinata)\
**Post date:** [April 2, 2024, 5:07pm UTC](https://community.hubspot.com/t/pagination-breaks-sorting-order/103929/1 "2024-04-02T17:07:43Z")

</div>

Hi all  
I have a blog listing page which required to sort the post based on the updated time. And in this listing, we have a numbered pagination too (based on the one from Boilerplate theme)  
However, the sort breaks when reached page 2.

```lia-code-sample
{% if contents %}
 {% set sorted_contents = contents|sort(True, False, 'updatedDateTime') %}
 {% for content in sorted_contents %}
 <div class="col-12 col-lg-4 mb-4 post-item">
 <div class="card">
 <div class="card-header">
 <a href="{{ content.absolute_url }}">
 <img src="{{content.featured_image}}" alt="{{ content.name }}" class="card-img" />
 </a>
 </div>
 <div class="card-body">
 <h3 class="card-title">
 <a href="{{ content.absolute_url }}"
 >{{ content.name }}</a
 >
 </h3>
 <p class="card-text">
 {{ content.post_list_content|striptags|truncate(200, True, "...") }}
 </p>
 <a href="{{ content.absolute_url }}" class="read-more"
 ><span class="decoration-underline">{{button_caption}}</span>
 <span class="decoration-none">⟶</span></a
 >
 </div>
 </div>
 </div>
 {% endfor %}
 {% endif %}

```

Is there any thoughts to tackle this ? 🙂

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [April 8, 2024, 3:08pm UTC](https://community.hubspot.com/t/pagination-breaks-sorting-order/103929/2 "2024-04-08T15:08:35Z")

</div>

Hi @PWinata,  
Thank you for sharing the code and for asking the Community!  
I’d like to invite a couple of subject matter experts to this conversation: Hi @Teun, @BarryGrennan, @eyeson and [@ChehakWadhdwa](https://community.hubspot.com/t5/user/viewprofilepage/user-id/345416) do you have tips to help @PWinata, please?  
Also, if anybody else has anything to add and/or share, please feel free to join in the conversation 🙂  
Thanks a lot and have a great day!  
Best,  
Bérangère

---

<div class="post-metadata">

**Author:** ![PWinata](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@PWinata](https://community.hubspot.com/u/PWinata)\
**Post date:** [April 18, 2024, 8:10am UTC](https://community.hubspot.com/t/pagination-breaks-sorting-order/103929/3 "2024-04-18T08:10:14Z")

</div>

Hi Everyone 🙂  
How are you doing?  
have any solutions yet?  
we’re stuck 😄  
Thanks!  
Regards,  
Putu
