# Question Answer Plugin

**URL:** https://meta.discourse.org/t/question-answer-plugin/56032
**Category:** Plugin
**Tags:** deprecated
**Created:** [January 19, 2017, 4:43pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032 "2017-01-19T16:43:47Z")
**Posts on this page:** 1
**Showing post:** 267

<div class="post-metadata">

### Author: ![dfriestedt](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@dfriestedt](https://meta.discourse.org/u/dfriestedt)
#### Post date: [December 2, 2020, 10:58pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/267 "2020-12-02T22:58:59Z")

</div>

Moving this discussion over here from #Support

I’m running 2.7.0.beta1 and when I installed the Q&A plugin replies to posts started to appear in random order. Others started to exhibit the same issues identified in this thread.

> [@Replies in thread showing out of order](https://meta.discourse.org/t/replies-in-thread-showing-out-of-order/166512/9):
>
> I don’t understand it either, I couldn’t find any reason for it when looking through the code. Something seems to modify the sort order, but I can’t see what. I thought that they had gone out of order when I ran an upgrade, as the messages that were out of order were generally much older, and had previously appeared in an expected place. When I fan the SQL above all seemed well, but then the other week a couple of brand new posts have also now appeared out of order. I think the posts it affects…

@AJDurant came up with this query (below) to fix the order issue, but it did not solve the problem. The plugin still seems to post replies to posts in the wrong order. I uninstalled the plugin and ran:

`rake posts:reorder_posts[1896]`

but it did not reorder the previous posts.

I’m afraid to run this query without further investigation by someone qualified to evaluate the fix. Any thoughts on how to fix this?

```
 SELECT
    id,
    ROW_NUMBER() OVER (
      PARTITION BY
        topic_id
      ORDER BY
        created_at,
        post_number
    ) AS new_post_number
  FROM
    posts
  /*where*/
)
UPDATE
  posts AS p
SET
  sort_order = o.new_post_number
FROM
  ordered_posts AS o
WHERE
  p.id = o.id AND
  p.sort_order <> o.new_post_number

```

---

_[View the full topic](https://meta.discourse.org/t/question-answer-plugin/56032)._
