Case-insensitive Sort
Closed this issue · 2 comments
The sort function that was added uses StringComparer.Ordinal
, making it case-sensitive. This messes up the order of all of my resx files because the previous extension I had for older versions of VS sorted case-insensitively.
I'm not sure whether this was intentional, since the Sort.resx
test case is very simple with three lower-case strings.
abc
def
ghi
However when you try to sort resx
files with mixed-case strings, they don't come out in case-insensitive order:
Alaska
ARIZONA
Aardvark
amazing
ABOUT
Is sorted as:
ABOUT
ARIZONA
Aardvark
Alaska
amazing
Describe the solution you'd like
What I would like this to sort as would be in pure alphabetical order, regardless of case:
Aardvark
ABOUT
Alaska
amazing
ARIZONA
To do this requires using StringComparer.OrdinalIgnoreCase
instead of StringComparer.Ordinal
.
I have a patch which adds a new option, resx_formatter_sort_entries_case_sensitive
. This works in conjunction with resx_formatter_sort_entries
so that if resx_formatter_sort_entries
is false, the new option is ignored.
I have not added a test case yet but can quite easily once it's said that this is a feature you want to add.
I have half a mind to just change this behavior, but I guess not everybody would be too happy about this. Thanks for your suggestion, it inspired me to make the following new setting that allows you to configure the extension this way:
resx_formatter_sort_comparer=OrdinalIgnoreCase
This setting is optional and if not set the extension behaves as before i.e. uses StringComparerOrdinal
. Currently only these two are supported, but I guess I will just all of them for the sake of completeness.
Feel free to use the CI build and let me know if it behaves as expected. Eventually I will get around to properly release a new version, so stay tuned :-)
I did some playing around with the CI build yesterday using the OrdinalIgnoreCase
setting and it's behaving pretty much as I'd expect.
Your change is also much more extensive than mine. I guess that happens when you're that familiar with the codebase.