User:PC-XT/ParticipantSort.js

function sortParticipantList(mergeCmts,sp){ //sort only first list section for now var all=document.getElementById("wpTextbox1").value.split("\n"),L,a=[],b=[],q=function(a,b){return a.k>b.k?1:a.k==b.k?0:-1;}/*return a.k.localeCompare(b.k,"en"?,{sensitivity:"base"});*/,nd="",i,j,r="",rx="",x={},t={ //only for alphabetical order of usernames, not necessarily true Latinization a:"àáââãäåăąā", ae:"æǽǣ", c:"çčćĉċ", d:"ðďđḍ", e:"èéêëěęėĕēẽẹǝə", g:"ĝğġģ", h:"ĥħḥ", i:"ìíîïĩīĭǐįıị", j:"ĵ", k:"ķ", l:"ĺļľŀłḷḹ", m:"ṃ", n:"ñńņṇňŉŋ", o:"òóôõőöǒŏōǫọø", oe:"œ", r:"ŕŗřṛṝ", s:"šșşśŝṣß", t:"țţťṭ", u:"űũùúûüůǔŭūůųụǘǜǚǖ", w:"ŵ", y:"ýÿŷỹȳ", z:"žżź", "":"\\-–—−·_.,@!?#*%"+(sp?"":" "), " ":"}" }; for(i in t){rx+=t[i];for(j=0;j<t[i].length;j++)x[t[i].substring(j,j+1)]=i;}

for(i=0;i2?t[2]:all[i]).toLowerCase.replace(new RegExp('['+rx+']','g'),function(k){return x[k];})}); else if(all[i].substring(0,1)=="=")break; //else if(":; ".indexOf(all[i].substring(0,1))); else nd+="\n"+all[i]; for(i<all.length;i++)nd+="\n"+all[i];

a=a.sort(q);//sort names for(i=0;i<a.length;i++)r+=a[i].s+"\n";

if(b.length){//possible 2nd name list r+="\n"; b=b.sort(q); for(i=0;i<b.length;i++)r+=b[i].s+"\n"; }

document.getElementById("wpTextbox1").value=r+nd;document.getElementById('wpSummary').value+="(User:PC-XT/ParticipantSort)";} mw.util.addPortletLink('p-tb','javascript:sortParticipantList(confirm("merge comments?"),confirm("count space?"))','Sort Participant List','p-tb-sortParticipantList');