-
-
Save mattn/243860 to your computer and use it in GitHub Desktop.
ペヨン順
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "sort"; | |
type PeYon []string | |
func (p PeYon) Len() int { | |
return len(p); | |
} | |
func (p PeYon) Less(i, j int) bool { | |
return p[i] < p[j]; | |
} | |
func (p PeYon) Swap(i, j int) { | |
p[i], p[j] = p[j], p[i] | |
} | |
func main() { | |
peyon := []string{ "\u30f3", "\u9806", "\u30da", "\u30e8" }; | |
peyonjun := make(PeYon, len(peyon)); | |
for i, v := range peyon { peyonjun[i] = v } | |
// はーい!ぺよん順に並んで! | |
sort.Sort(peyonjun); | |
for _, v := range peyonjun { print(v) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment