Numerical StringComparer coming in .NET 10

This enables comparisons of numbers based on their numerical value instead of lexicographical order.

In the example below with Ordinal sorting, since 1 comes before 7, the list outputs as ‘Windows 10, Windows 7’. From .NET 10 Preview 1 we can use the StringComparer.NumbericOrdering option to force .NET to sort based on the list items logical numeric values.

PR -> https://github.com/dotnet/runtime/pull/109861
Issue -> https://github.com/dotnet/runtime/issues/13979

What do you think?
Useful API addition?

Leave a Reply

Your email address will not be published. Required fields are marked *