Tobias, 

The C# code is likely using the string sort method: SORT_STRINGSORT.

winnls.h:

//    STRING Sort:  hyphen and apostrophe will sort with all other symbols
//
//                        co-op     <-------  hyphen (punctuation)
//                        co_op     <-------  underscore (symbol)
//                        coat
//                        comb
//                        coop
//                        cork
//                        we're     <-------  apostrophe (punctuation)
//                        went
//                        were
//
#define SORT_STRINGSORT           0x00001000  // use string sort method

InvariantCulture means independent of culture (and language). The sort 
returns the same results for the US, Germany, and Azerbaijan.

Peter

On Wednesday, July 28, 2021 at 3:49:27 AM UTC-4 klau...@schwarzvogel.de 
wrote:

> Hi! 
>
> On Wed, 28 Jul 2021, James wrote:
> > It could be that .NET is using some locale based collation. Seems like a
> > lot of machinery, but might do the trick
> > https://pkg.go.dev/golang.org/x/te...@v0.3.6/collate 
> <https://pkg.go.dev/golang.org/x/text@v0.3.6/collate>
>
> I have managed to get the .NET code used for sorting:
>
> Files.Sort((x, y) => string.Compare(x.RelativePath, y.RelativePath, 
> CultureInfo.InvariantCulture,
> CompareOptions.IgnoreCase));
>
> My NET-fu is weak, but I do wonder what exactly
> `CultureInfo.InvariantCulture` means in the context of sorting.
>
> I'll do some more digging, but I suspect the only way I can match
> the .NET behavior 100% is indeed x/text/collate :-/
>
> Best,
> Tobias
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1b2fefda-f84c-4573-bf3d-7f71e4ee3b7dn%40googlegroups.com.

Reply via email to