Re: [go-nuts] Re: A peculiar sort problem

2021-07-28 Thread peterGo
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 (symbo

Re: [go-nuts] Re: A peculiar sort problem

2021-07-28 Thread Tobias Klausmann
Hi! On Tue, 27 Jul 2021, Tamás Gulácsi wrote: > First, sort all the bytes (0-255) with Go and .Net, and compare them. > For Unicode-unaware sorting, that'd be enough: create a mapping between the > two tables, > replace all the bytes in the Go's input before sort (or use a Less that > does the

Re: [go-nuts] Re: A peculiar sort problem

2021-07-28 Thread Tobias Klausmann
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/text@v0.3.6/collate I have managed to get the .NET code used for sorting: Files.Sort((x, y) => string.Com

Re: [go-nuts] Re: A peculiar sort problem

2021-07-27 Thread James
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/text@v0.3.6/collate On Wed, 28 Jul 2021 at 06:52, jake...@gmail.com wrote: > Personally I would be careful about assuming that was the only sorting >

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Brian Candler
As a complete guess: perhaps the .NET sorter is replacing underscore with space before sorting? You'll need to do some further experimentation to prove or disprove this theory. But if it's true, you can change your Less function in a corresponding way. Of course, that still begs the question

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Tamás Gulácsi
First, sort all the bytes (0-255) with Go and .Net, and compare them. For Unicode-unaware sorting, that'd be enough: create a mapping between the two tables, replace all the bytes in the Go's input before sort (or use a Less that does the translation), thus replicating the .NET sort order. ampl

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread jake...@gmail.com
Personally I would be careful about assuming that was the only sorting difference. Unless you have checked every Unicode character, there could be other hidden 'special cases'. If it *really *mattered, personally, I would dig into the .NET library source code and see what algorithm or system cal