An option should exist at
admin/structure/types/manage/[contenttype]
that gives users the option to sort comments with either the defaul option "Oldest First" (ASC) or "Newest First" (DESC)
If the comments on threaded the threads should be preserved properly.

this should be achieved by ordering the comments by "thread" DESC. (without the default substring).

so this..

  $query->addExpression('SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))', 'torder');
  $query->orderBy('torder', 'ASC');

should become this:

  $query->orderBy('c.thread', 'DESC');

Obviously conditions and constants should be added to allow the user to have a choice.

thanks!

Comments

davidwbarratt’s picture

Assigned: davidwbarratt » Unassigned
Status: Active » Needs review

Here is a module that someone has written that accomplishes this feature:
http://drupal.org/project/sort_comments

it would be nice if this was part of core.

thanks!
david

Tenchu2525’s picture

Agreed

dddave’s picture

Title: Ability to Sort Comments DESC (Newest First) » Ability to sort threaded comments DESC (Newest First)
Version: 7.2 » 7.x-dev
Status: Needs review » Active
Issue tags: -comments, -sort

Correcting settings and title.

As contrib provides a solution I have my doubts if something will be included into D7.

mdupont’s picture

Status: Active » Closed (won't fix)

I think it is best to use a contrib module or a block generated by Views module to achieve that. The reason is it very unlikely to be added to Drupal core is because few sites will use it. I mean, I have almost never seen a site that displays comments in descending order. Closing the issue.

yseki’s picture

Issue tags: +comment, +order desc

to order comment desc, do that

    $query = db_select('comment', 'c')
        ->extend('PagerDefault')->limit(20);
    $query->distinct();
    $query->addField('c', 'cid');
    $query->condition('c.nid', $node->nid, '=');
    $query->orderBy('c.thread', 'DESC');
    $cids = $query->execute()->fetchCol();

    $comments = comment_load_multiple($cids);
    comment_prepare_thread($comments);
    $var_comments = comment_view_multiple($comments, $node, 'full');
    $output = theme('pager') . render($var_comments) . theme('pager');
emergencyofstate’s picture

^ yuriseki, how would one implement this code?

brycesenz’s picture

+1 for putting this back into Drupal core. The contrib module seems abandoned is still riddled with bugs.

@mdupont - Many major sites that I'm sure you've seen (e.g. YouTube) display newer comments first.

In any case, the solution is a bit more complicated than comment #5 when you get into threaded comments. I believe that the desired functionality there is that the comments are ordered DESC by the comment root, but ordered ASC for all replies to that comment.

bkosborne’s picture

FYI - this screws up the linking of comments. Since we are just controlling the sort order, the comment links on the comment moderation page (/admin/content/comments in d7) link to the wrong page when anchoring to a comment.

David_Rothstein’s picture

Status: Closed (won't fix) » Closed (duplicate)

This feature existed in Drupal 6 but was deliberately removed in Drupal 7. The issue where it's being discussed is #191499: Remove "Display order" from comment settings.

P3t3r’s picture

So, since this is not going into core again, what module / technique / ... should one use to have this functionality?

To clarify, I mean the behavior that most large sites use, like brycesenz puts it: "the comments are ordered DESC by the comment root, but ordered ASC for all replies to that comment".

greenwork’s picture

The contrib module seems not to work. Why was this removed. I can think of many larger pages that have newest first.. EX facebook

greenwork’s picture

Ok here is another contrib module that is working on some sites and at least has a stable release

http://drupal.org/project/comment_goodness