Skip to content

Commit 5f65691

Browse files
author
Ravbug
committed
case insensitive sort
1 parent 281baf2 commit 5f65691

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

source/interface_derived.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,19 @@ int wxCALLBACK MainFrameDerived::CompareItems(wxIntPtr item1, wxIntPtr item2, wx
762762

763763
int result = 0;
764764

765+
constexpr static auto toLower = [](std::string data) {
766+
std::transform(data.begin(), data.end(), data.begin(),
767+
[](unsigned char c) { return std::tolower(c); });
768+
return data;
769+
};
770+
765771
switch (frame->sortColumn) {
766-
case 0: // Name
767-
result = p1.name.compare(p2.name);
772+
case 0: { // Name
773+
auto p1Name = toLower(p1.name);
774+
auto p2Name = toLower(p2.name);
775+
776+
result = p1Name.compare(p2Name);
777+
}
768778
break;
769779
case 1: { // Version
770780
auto v1 = parseVersion(p1.version);
@@ -788,7 +798,12 @@ int wxCALLBACK MainFrameDerived::CompareItems(wxIntPtr item1, wxIntPtr item2, wx
788798
result = int(std::clamp<int64_t>(p2.modifiedDate - p1.modifiedDate,-10,10));
789799
break;
790800
case 3: // Path
791-
result = p1.path.string().compare(p2.path.string());
801+
{
802+
auto p1path = toLower(p1.path.string());
803+
auto p2path = toLower(p2.path.string());
804+
805+
result = p1path.compare(p2path);
806+
}
792807
break;
793808
}
794809

0 commit comments

Comments
 (0)