Skip to content

Commit

Permalink
Sort configs in config menu by name
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed May 7, 2024
1 parent f9b67d5 commit ac05cf8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/utils/config/ConfigUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <coreinit/screen.h>
#include <gx2/display.h>
#include <memory/mappedmemory.h>
#include <ranges>
#include <string>
#include <vector>

Expand Down Expand Up @@ -123,6 +124,21 @@ void ConfigUtils::displayMenu() {
configs.emplace_back(info, std::move(config));
}

// Sort Configs by name
std::sort(
configs.begin(),
configs.end(),
[](const ConfigDisplayItem &lhs, const ConfigDisplayItem &rhs) {
auto &str1 = lhs.getConfigInformation().name;
auto &str2 = rhs.getConfigInformation().name;
return lexicographical_compare(
begin(str1), end(str1),
begin(str2), end(str2),
[](const char &char1, const char &char2) {
return tolower(char1) < tolower(char2);
});
});

ConfigRenderer renderer(std::move(configs));
configs.clear();

Expand Down

0 comments on commit ac05cf8

Please sign in to comment.