Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: I18N "Add helper for localized sorting"
Purpose of change
The issue of sorting (collating) strings in the game has come up a few times. Currently it's always done by just sorting byte-wise, which is equivalent to sorting lexicographically by codepoint. That's acceptable for English, but not that great for many other languages.
I thought there was nothing we could really do about this without adding a heavyweight dependency like ICU, but I recently discovered that the standard library does have some support for localized sorting, which might not be the Unicode Collation Algorithm, but might be better than the status quo.
Describe the solution
Add a helper struct to be used as a comparison functor when performing localised sorting.
Use it to sort the translated names in the debug vehicle spawn menu.
I picked this list as a first test case because it's long, and thus ought to demonstrate most ways in which sorting can go wrong, but also a low-impact change that's safe for an experiment like this.
Note that this is implemented via translate-up-front and then sort, so there are no more translations than there were in the previous implementation, so there will be no performance impact from extra translations (there is potential for performance impact from slower comparison, but I have not observed any).
Describe alternatives you've considered
Using ICU for full-blown Unicode collation. Or keeping the status quo. Or rolling our own.
Testing
Tested for German on Linux (see screenshot below).
I'm not sure how this will fare for other languages / platforms. I'm making this a small change to facilitate testing before rolling out more widely.
Additional context
Screenshot of sorted German names:
Observe in particular that Käfer correctly sorts before Kajak, whereas in codepoint order it would appear after Kreuzspaltung.