diff --git a/server/src/world/worldlist.cpp b/server/src/world/worldlist.cpp index c82e085f..e43dba10 100644 --- a/server/src/world/worldlist.cpp +++ b/server/src/world/worldlist.cpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2019-2020,2022-2023 Reinder Feenstra + * Copyright (C) 2019-2020,2022-2024 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -98,7 +98,7 @@ void WorldList::buildIndex() } } - std::sort(m_items.begin(), m_items.end(), [](const WorldInfo& a, const WorldInfo& b) -> bool { return a > b; }); + sort(); //for(auto& model : m_models) // model->setRowCount(m_items.size()); @@ -138,3 +138,12 @@ bool WorldList::readInfo(const json& world, WorldInfo& info) return !info.uuid.is_nil(); } + +void WorldList::sort() +{ + std::sort(m_items.begin(), m_items.end(), + [](const WorldInfo& a, const WorldInfo& b) -> bool + { + return a > b; + }); +} diff --git a/server/src/world/worldlist.hpp b/server/src/world/worldlist.hpp index 3a8d4331..afa83ee7 100644 --- a/server/src/world/worldlist.hpp +++ b/server/src/world/worldlist.hpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2019-2020,2023 Reinder Feenstra + * Copyright (C) 2019-2020,2023-2024 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -45,10 +45,13 @@ class WorldList : public Object, public Table bool operator >(const WorldInfo& that) const { - return name.compare(that.name) > 0; + return strcasecmp(name.c_str(), that.name.c_str()) < 0; } }; + private: + void sort(); + protected: static bool readInfo(const nlohmann::json& world, WorldInfo& info);