# Incorrect initial order when user sorts topic list

**URL:** https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504
**Category:** Bug
**Created:** [November 15, 2023, 3:02am UTC](https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504 "2023-11-15T03:02:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![per1234](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/per1234/32/569645_2.png) [@per1234](https://meta.discourse.org/u/per1234)
#### Post date: [November 15, 2023, 3:02am UTC](https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504/1 "2023-11-15T03:02:22Z")

</div>

### Priority/Severity:

Medium

### Platform

#### Operating System

- Windows 11
- macOS Sonoma

#### Browser

- Google Chrome 119.0.6045.124
- Safari 17.1 (19616.2.9.11.7)

#### Discourse

38e53b5e8eab64225879a1b855bc50242f2791e5

### Description:

The user can choose to sort lists of topics by:

- Number of replies
- Number of views
- Timestamp of latest activity

The criterion by which to sort is selected by clicking the associated column heading.

The sort order is toggled between ascending and descending by subsequent clicks on the column. A **˄** symbol suffix on the heading indicates ascending sort order and a **˅** symbol indicates descending sort order.

🐛 On the first click on the column, the ascending symbol appears even though the list is sorted in descending order.

🐛 On the second click on the column, the sort order does not toggle.

### Reproducible steps:

1. Open any topic list:  
[https://try.discourse.org/](https://try.discourse.org/)
2. Click the “ **Views** ” column heading.  
🐛 The **˄** ascending symbol appears next to the column heading even though the list is sorted in descending order.
3. Click the “ **Views** ” column heading.  
🐛 The sort order of the column remains descending instead of switching to ascending as expected.  
🙂 The sort order symbol changes to **˅** , matching the current sort order.
4. Click the “ **Views** ” column heading.  
🙂 The sort order toggles from descending to ascending.  
🙂 The sort order symbol changes to **˄** , matching the new sort order.
5. Click the “ **Views** ” column heading.  
🙂 The sort order toggles from ascending to descending.  
🙂 The sort order symbol changes to **˅** , matching the new sort order.

### Additional context

I notice that the **˅** symbol is shown momentarily after the column is selected, before changing to **˄** :

![sort](https://global.discourse-cdn.com/meta/original/4X/b/9/9/b9979cc16df7cdfb5104044fc993dd631a593be0.gif)

* * *

I am able to reproduce the fault on [try.discourse.org](http://try.discourse.org) in “[safe mode](https://meta.discourse.org/t/how-to-use-discourse-safe-mode/53504)”.

* * *

Originally reported at [Issue with sorting new posts by number of replies - Website and Forum - Arduino Forum](https://forum.arduino.cc/t/issue-with-sorting-new-posts-by-number-of-replies/1189159)

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [November 15, 2023, 3:14am UTC](https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504/2 "2023-11-15T03:14:02Z")

</div>

Yup, I can repro here on Meta also.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 20, 2023, 4:22pm UTC](https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504/7 "2023-11-20T16:22:18Z")

</div>

Thanks for the report @per1234 - we have a [fix in the pipeline](https://github.com/discourse/discourse/pull/24465) for this

**EDIT** merged and deployed.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 21, 2023, 5:46am UTC](https://meta.discourse.org/t/incorrect-initial-order-when-user-sorts-topic-list/285504/8 "2023-11-21T05:46:11Z")

</div>


