From: Oleg Broytman Date: Fri, 31 Mar 2006 17:57:01 +0000 (+0000) Subject: Sort all_tags by count in descending order, and by tags and links in ascending order. X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=c16fedde035dea3d7e94ea3389d2de54d095cea1;p=phdru.name%2Fphdru.name.git Sort all_tags by count in descending order, and by tags and links in ascending order. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@47 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- diff --git a/reindex_blog.py b/reindex_blog.py index b75104d..f650542 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -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)