]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Sort all_tags by count in descending order, and by tags and links in ascending order.
authorOleg Broytman <phd@phdru.name>
Fri, 31 Mar 2006 17:57:01 +0000 (17:57 +0000)
committerOleg Broytman <phd@phdru.name>
Fri, 31 Mar 2006 17:57:01 +0000 (17:57 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@47 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

reindex_blog.py

index b75104df2c2a18f4be44d37672580e63d7590589..f6505421239d531233636126b7f9ad1a91da68cb 100755 (executable)
@@ -299,8 +299,17 @@ for year in sorted(years.keys()):
       write_template(2, year, month, day, month_titles)
    write_template(1, year, month, day, year_titles)
 
+def by_count_rev_tag_link(t1, t2):
+   """Sort all_tags by count in descending order,
+   and by tags and links in ascending order
+   """
+   r = cmp(t1[0], t2[0])
+   if r:
+      return -r
+   return cmp((t1[1], t1[2]), (t2[1], t2[2]))
+
 all_tags = [(len(links), tag, links) for (tag, links) in all_tags.items()]
-all_tags.sort()
+all_tags.sort(by_count_rev_tag_link)
 
 write_template(0, year, month, day, all_titles[-20:], all_tags)