exports.sortbycount=function(t,e){var i=$tw.wiki,n=i.getTiddler("$:/temp/CPL-Server/all-plugin-stats"),l={};if(n&&n.fields.text)try{l=JSON.parse(n.fields.text).plugins||{}}catch(o){}i.each(function(t){var e=t.fields["plugin-title"];if(e&&!l[e]&&0===String(t.fields.title||"").indexOf("$:/cpl/download-stats/"))try{var n=JSON.parse(t.fields.text||"{}");"number"==typeof n.downloadCount&&(l[e]=n)}catch(o){}});var r=[],n=(t(function(t,e){var n=i.getTiddler(e),n=n&&n.fields["cpl.title"]||e,n=l[n]&&l[n].downloadCount||0;r.push({title:e,count:n})}),r.sort(function(t,e){return e.count!==t.count?e.count-t.count:t.title<e.title?-1:e.title<t.title?1:0}),parseInt(e.operand||"",10)),n=Math.min(Math.max(0,isNaN(n)?r.length:n),r.length);return r.slice(0,n).map(function(t){return t.title})};