summaryrefslogtreecommitdiffstats
path: root/source/core/slang-command-options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-command-options.cpp')
-rw-r--r--source/core/slang-command-options.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/core/slang-command-options.cpp b/source/core/slang-command-options.cpp
index a4bb8b552..30eaed333 100644
--- a/source/core/slang-command-options.cpp
+++ b/source/core/slang-command-options.cpp
@@ -333,7 +333,11 @@ void CommandOptions::addValuesWithAliases(const ConstArrayView<NameValue>& inVal
List<NameValue> values;
values.addRange(inValues.getBuffer(), inValues.getCount());
- values.sort([](const NameValue& a, const NameValue& b) -> bool { return a.value < b.value; });
+ // Use stable_sort to preserve the original order for names with the same value.
+ std::stable_sort(
+ values.begin(),
+ values.end(),
+ [](const NameValue& a, const NameValue& b) -> bool { return a.value < b.value; });
List<UnownedStringSlice> names;
@@ -346,6 +350,7 @@ void CommandOptions::addValuesWithAliases(const ConstArrayView<NameValue>& inVal
const auto value = values[i].value;
names.add(UnownedStringSlice(values[i++].name));
+ // For all names with the same value, preserve their original order (primary first)
for (; i < count && values[i].value == value; ++i)
{
names.add(UnownedStringSlice(values[i].name));