Sort tags by number of occurrences first, then alphabetically.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-05-18 15:13:27 +02:00
parent 7093719199
commit 3d19b9a1d2
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 11 additions and 1 deletions

View File

@ -116,7 +116,17 @@ void export_adoc(const vector<Database::entry> &entries, ostream &out)
std::sort(sortedtags.begin(), sortedtags.end(),
[](const tagpair &a, tagpair &b)
{
return a.second.size() > b.second.size();
// return a.second.size() > b.second.size();
if (a.second.size() != b.second.size())
{ // Sort by number of occurrences if they are
// different.
return a.second.size() > b.second.size();
}
else
{ // Sort alphabetically otherwise.
// TODO: Does this work with non-latin languages?
return a.first < b.first;
}
});
for (const auto &tag : sortedtags)