Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.4k views
in Q2A Core by
How to change the asc/desc chrono sort order for answers in the question view page? I mean, show the newest answers and comments first and oldest answers last?
Q2A version: 1.5

2 Answers

0 votes
by

please have a look in the admin-interface at "View":

and set "Sort answers by:" from "votes" to "time".

by
Thanks, but the order of answers still defaults to oldest at top whether you use time or votes method. I need answers to be displayed chronologically in descending order with newest answer shown first beneath the question. It is the opposite right now.
+1 vote
by

You can use PHP's array reversing function after the line qa_sort_by($answers, 'created'); in qa-page-question.php

by
Thanks. I'm trying to figure it out, but not sure exactly what to do. So I'll do some learning an legwork before asking the the actual code to put there. In the mean time, perhaps it would be a nice core function for admin to be able to specify to show answers from "newest to oldest" vs. "oldest to newest".
by
sorry, redundant info: see below...
by
I tried this code: It sorts all answers, including voted-up answers, from newest to oldest. Is there a way to have answers newest to oldest while still allowing up-voted answers to appear at the top?

    if (qa_opt('sort_answers_by')=='votes') {
        foreach ($answers as $answerid => $answer)
            $answers[$answerid]['sortvotes']=$answer['downvotes']-$answer['upvotes'];

        qa_sort_by($answers, 'sortvotes', 'created');

    } else
        qa_sort_by($answers, 'created');
        $answers = array_reverse($answers, true);
by
Thank you for sharing this code!
...