troll comments on Sorting Comments - Less Wrong

-11 Post author: troll 24 April 2013 04:35PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (10)

You are viewing a single comment's thread. Show more comments above.

Comment author: troll 25 April 2013 03:35:17AM *  1 point [-]

Yup. I did that first thing.

But how do I sort the comments by new (and as a list?) Seeing only new comments is useful, but what about chronological ordering for all comments?

Comment author: endoself 25 April 2013 05:43:21PM 3 points [-]
(function($) {if($('.new-comment').length > 0) { var time = function(c) { return parseInt(jQuery(c).find('.comment-date').attr('time')); }; var new_comments = $('.new-comment').sort(function(a, b) { return time(b) - time(a); }); $('.realcomment').after(new_comments); }})(jQuery);

This should work. I put the newest ones first, but you can switch that by changing

time(b) - time(a)

to

time(a) - time(b)