Moved tagpair-lambda up for better readability.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b4fb62b15a
commit
da88eaf703
|
@ -183,25 +183,27 @@ namespace remwharead
|
||||||
_out << "== Tags\n\n";
|
_out << "== Tags\n\n";
|
||||||
vector<tagpair> sortedtags(tags.size());
|
vector<tagpair> sortedtags(tags.size());
|
||||||
std::move(tags.begin(), tags.end(), sortedtags.begin());
|
std::move(tags.begin(), tags.end(), sortedtags.begin());
|
||||||
std::sort(sortedtags.begin(), sortedtags.end(),
|
|
||||||
[](const tagpair &a, tagpair &b)
|
const auto compare_tags =
|
||||||
{
|
[](const tagpair &a, tagpair &b)
|
||||||
if (a.second.size() != b.second.size())
|
{
|
||||||
{ // Sort by number of occurrences if they are different.
|
if (a.second.size() != b.second.size())
|
||||||
return a.second.size() > b.second.size();
|
{ // Sort by number of occurrences if they are different.
|
||||||
}
|
return a.second.size() > b.second.size();
|
||||||
else
|
}
|
||||||
{ // Sort by tag names otherwise.
|
else
|
||||||
std::locale loc;
|
{ // Sort by tag names otherwise.
|
||||||
const std::collate<char> &coll =
|
const std::locale loc;
|
||||||
std::use_facet<std::collate<char>>(loc);
|
const std::collate<char> &coll =
|
||||||
return (coll.compare(
|
std::use_facet<std::collate<char>>(loc);
|
||||||
a.first.data(), a.first.data()
|
return (
|
||||||
+ a.first.length(),
|
coll.compare(
|
||||||
b.first.data(), b.first.data()
|
a.first.data(), a.first.data() + a.first.length(),
|
||||||
+ b.first.length()) == -1);
|
b.first.data(), b.first.data() + b.first.length())
|
||||||
}
|
== -1);
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
std::sort(sortedtags.begin(), sortedtags.end(), compare_tags);
|
||||||
|
|
||||||
bool othertags = false; // Have we printed “Less used tags” already?
|
bool othertags = false; // Have we printed “Less used tags” already?
|
||||||
for (const auto &tag : sortedtags)
|
for (const auto &tag : sortedtags)
|
||||||
|
|
Loading…
Reference in New Issue