"Ladsgroup" posted a comment on pywikipedia.r10152.
URL: http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10152#c32791
Commit summary for pywikipedia.r10152:
Adding categories sort for Persian Wikipedia
Ladsgroup's comment:
There is a problem in sorting in Persian:
*list.sort() doesn't work properly and takes "پ","چ","گ","ژ","ی","ک" (letters
doesn't exist in Arabic language) and Persian numbers ("۱۲۳۴۵۶۷۸۹۰") to end of
letters. So I wrote another code and main cat is:
<pre>
def persian_sort(categorylist):
finallradeh,s_radeh=[],[]
alphabets=u' ۰۱۲۳۴۵۶۷۸۹آابپتثجچحخدذرزژسشصضعغفقکگلمنوهی' #Space is first
then numbers and then correct Alphabet letter and after all of letters is ZWNJ
for radeh in categorylist:
radeh=radeh.replace(u'[[رده:',u'').replace(u']]',u'')
coderadeh=radeh
for i in range(0,len(alphabets)):
alphabet=alphabets[i]
if i<10:
j='0'+str(i)
else:
j=str(i)
coderadeh=coderadeh.replace(alphabet,j)
s_radeh.append(coderadeh+u'0000000000000000000@@@@'+radeh)
s_radeh=list(set(s_radeh))
sortedradeh=sorted(s_radeh)
for radeh in sortedradeh:
radeh=u'[[رده:'+radeh.split(u'@@@@')[1]+u']]'
finallradeh.append(radeh)
return finallradeh
</pre>
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview