Created
December 18, 2014 06:03
-
-
Save bakkot/1ab53b25907bfc82d780 to your computer and use it in GitHub Desktop.
SSC sort by number of children (only top-level threads)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:function c(l){return l.querySelectorAll('li.comment').length;}function s(e){var h=[];for(var i=0; i<e.children.length; ++i){h.push({'E':e.children[i],'C':c(e.children[i])});}var t=h.sort(function(a,b){return a.C-b.C;});for(var i=t.length-1;i>0;--i){e.insertBefore(t[i].E,t[0].E);}}s(document.querySelector('ol.commentlist')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment