Slide 22
Slide 22 text
ແ໊ؔ
package mai
n
import
(
"fmt
"
"sort
"
)
func main()
{
stations := []string{"וా", "ޱ", "ଂ৽ా", "Լؙࢠ", "ӏͷ", "প෦", "ଟຎ"
}
sort.Slice(stations, func(i, j int) bool
{
return len(stations[i]) > len(stations[j]) // ͞Λൺֱ
}
)
fmt.Println(stations[0]) // ଂ৽ా
}
w sort.Slice()ͷΑ͏ͳؔΛཁٻ͢ΔؔͰɺͦͷͰແ໊ؔΛ࡞ͬ
ͯ͢͜ͱ͕Ͱ͖Δ
w ͜ͷؔͷؔఆٛҎԼͷΑ͏ʹͳ͍ͬͯΔ
func Slice(x interface{}, less func(i, j int) bool)