Repository: go
Issue: x/text/collate: incorrect sorting of Slovak words
Labels: NeedsInvestigation

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.17 linux/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes.


### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jano7/.cache/go-build"
GOENV="/home/jano7/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jano7/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jano7/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jano7/Documents/prog/golang/tmp/sortwords/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2259433300=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?
```
package main

import (
	"fmt"

	"golang.org/x/text/collate"
	"golang.org/x/text/language"
)

func main() {

	words := []string{"čaj", "auto", "pot", "márny", "kľak", "chyba", "drevo",
		"cibuľa", "džíp", "džem", "šum", "pól", "čučoriedka", "banán", "čerešňa",
		"červený", "klam", "čierny", "tŕň", "pôst", "hôrny", "mat", "chobot",
		"cesnak", "kĺb", "mäta", "ďateľ", "troska", "sýkorka", "elektrón",
		"fuj", "zem", "guma", "hora", "gejzír", "ihla", "pýr", "hrozno",
		"jazva", "džavot", "lom"}

	c := collate.New(language.Slovak)
	c.SortStrings(words)

	fmt.Println(words)
}
```

```
$ go run sort_accented_words.go 
[auto banán cesnak cibuľa čaj čerešňa červený čierny čučoriedka ďateľ drevo džavot džem 
džíp elektrón fuj gejzír guma hora hôrny hrozno chobot chyba ihla jazva kľak klam kĺb lom 
márny mat mäta pól pot pôst pýr sýkorka šum tŕň troska zem]
```
This is not 100% correct solution. (Still quite good in comparison to other languages such as Java, C#, or Python.)
From the languages I have tested, Raku and Go provide the closest solutions. (Raku does accents right, but fails with 
digraphs.)

The following is the correct ordering of characters in Slovak language:

a, á, ä, b, c, č, d, ď, dz, dž, e, é, f, g, h, ch, i, í, j, k, l, ĺ, ľ, m, n, ň, o, ó, ô, p, q, r, ŕ, s, š, t, ť, u, ú, v, w, x, y, ý, z, ž

Note that plain characters always precede the accented ones. So the word ďateľ should go after drevo, the sequence 
kľak klam kĺb should be klam kĺb kľak, márny mat mäta should be mat márny mäta, pól pot pôst should be 
pot pól pôst,  and  tŕň troska should be troska tŕň. 

The words with digraph ch are correct. (The dž digraphs are probably also good. Not 100% sure because there is
an issue with ď.)

So the correct ordering should be:

```
$ go run sort_accented_words.go 
[auto banán cesnak cibuľa čaj čerešňa červený čierny čučoriedka drevo ďateľ džavot džem 
džíp elektrón fuj gejzír guma hora hôrny hrozno chobot chyba ihla jazva klam kĺb kľak lom 
mat márny mäta pot pól pôst pýr sýkorka šum troska tŕň zem]
```