javascript:(function(){document.getElementsByClass=function(a){
	var f=[],rE=new RegExp('(^|\\s)'+a+'(\\s|$)'),els=document.getElementsByTagName('*'),i;
	for(i=0;i<els.length;i+=1){
		if(rE.test(els[i].className)){
			f.push(els[i]);
		}
	}
	return(f.length)?f:null;
};
var FARK={
	clean:function(a){
		var n=a.firstChild,nN;
		while(n){
			nN=n.nextSibling;
			if(n.nodeType===3&&(!(/\S/).test(n.nodeValue))){
				a.removeChild(n);
			}
			n=nN;
		}
		return a;
	},
	cleanThem:function(){
		for(var i=0;i<this.sections.length;++i){
			this.clean(this.clean(this.sections[i]).firstChild);
		}
	},
	comments:function(tr){
		var tds=tr.getElementsByTagName('td'),commN=this.clean(tds[tds.length-1]).firstChild.firstChild.nodeValue;
		commN=parseInt(commN.replace(/[\(|\)]/g,''),10);
		commN=(isNaN(commN))?Infinity:commN;
		return commN;
	},
	sections:document.getElementsByClass('nilink'),
	sortByComments:function(){
		if(this.sections===null){return;}
		this.cleanThem();
		for(var i=0;i<this.sections.length;++i){
			var section=this.sections[i].firstChild.cloneNode(true),nodes=section.childNodes,a=[],nl=nodes.length;
			for(var b=0;b<nl;++b){
				a.push(nodes[b]);
			}
			nodes=a;
			nodes.shift();
			if(nodes.length>1){
				nodes.sort(this.threads);
				var tbody=document.createElement('tbody');
				for(var j=0;j<nodes.length;++j){
					tbody.appendChild(nodes[j]);
				}
				tbody.insertBefore(section.firstChild,tbody.firstChild);
				var frag=document.createDocumentFragment();
				frag.appendChild(tbody);
				this.sections[i].appendChild(frag);
				this.sections[i].removeChild(this.sections[i].firstChild);
			}
		}
	},
	threads:function(a,b){
		var c=FARK.comments(a),d=FARK.comments(b);
		return d-c;
	}
};
FARK.sortByComments();})();
