It seems that you are using .NET 6 or Core in the first case, which performs a "String sort" (https://learn.microsoft.com/en-us/dotnet/api/system.globalization.compareoptions).
To obtain the same results in both of environments, try this comparison:
string.Compare( test1, test2, CultureInfo.CurrentCulture, CompareOptions.StringSort )
or use the appropriate values for CultureInfo and CompareOptions.