diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index a5d26be301..f8c3f7ac37 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1445,7 +1445,9 @@ private: /** Sort grfs by name. */ static bool NameSorter(const GRFConfig * const &a, const GRFConfig * const &b) { - int i = StrNaturalCompare(a->GetName(), b->GetName(), true); // Sort by name (natural sorting). + std::string name_a = StrMakeValid(a->GetName(), SVS_NONE); // Make a copy without control codes. + std::string name_b = StrMakeValid(b->GetName(), SVS_NONE); // Make a copy without control codes. + int i = StrNaturalCompare(name_a, name_b, true); // Sort by name (natural sorting). if (i != 0) return i < 0; i = a->version - b->version;