patch: internal/reflectlite; demo: sort

This commit is contained in:
xushiwei
2024-06-21 13:21:16 +08:00
parent 10a47cdbbb
commit e188925d2b
6 changed files with 1203 additions and 0 deletions

View File

@@ -8,4 +8,16 @@ func main() {
for _, v := range vals {
println(v)
}
texts := []string{"apple", "banana", "cherry", "date", "elderberry", "fig"}
sort.Slice(texts, func(i, j int) bool {
leni, lenj := len(texts[i]), len(texts[j])
if leni != lenj {
return leni < lenj
}
return texts[i] < texts[j]
})
for _, v := range texts {
println(v)
}
}