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)