Stabilize article sorting by title in citeblocks and statistics page

This commit is contained in:
Tim Van Baak 2018-08-16 00:02:52 -07:00
parent f21213d673
commit 2e4f7f60a3
2 changed files with 11 additions and 3 deletions

View File

@ -182,7 +182,9 @@ class LexiconArticle:
"<a href=\"{1}.html\"{2}>{0}</a>".format(
title, utils.titleescape(title),
"" if title in self.wcites else " class=\"phantom\"")
for title in sorted(self.wcites | self.pcites)]
for title in sorted(
self.wcites | self.pcites,
key=lambda t: utils.titlesort(t))]
cites_str = " | ".join(cites_links)
if len(cites_str) < 1: cites_str = "&mdash;"
citeblock += "<p>Citations: {}</p>\n".format(cites_str)
@ -190,7 +192,9 @@ class LexiconArticle:
citedby_links = [
"<a href=\"{1}.html\">{0}</a>".format(
title, utils.titleescape(title))
for title in self.citedby]
for title in sorted(
self.citedby,
key=lambda t: utils.titlesort(t))]
citedby_str = " | ".join(citedby_links)
if len(citedby_str) < 1: citedby_str = "&mdash;"
citeblock += "<p>Cited by: {}</p>\n</div>\n".format(citedby_str)

View File

@ -160,7 +160,11 @@ def build_statistics_page(articles, config):
citation_count = defaultdict(list)
for title, count in citation_tally: citation_count[count].append(title)
content += "<br>\n".join(map(
lambda kv: "{0} &ndash; {1}".format(kv[0], "; ".join(kv[1])),
lambda kv: "{0} &ndash; {1}".format(
kv[0],
"; ".join(sorted(
kv[1],
key=lambda t: utils.titlesort(t)))),
sorted(citation_count.items(), reverse=True)[:3]))
content += "</p>\n"
content += "</div>\n"