Skip to content

Instantly share code, notes, and snippets.

@halllllll
Created March 28, 2018 05:14
Show Gist options
  • Save halllllll/4ae175d17fee528995a73397c7730c68 to your computer and use it in GitHub Desktop.
Save halllllll/4ae175d17fee528995a73397c7730c68 to your computer and use it in GitHub Desktop.
nihongo is muzukasii-
package main
import (
"fmt"
"sort"
"strings"
)
func main(){
message := "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑいもせす"
lnh := len([]rune(message))
ms := make([]string, lnh)
for i, v := range []rune(message){
ms[i] = string(v)
}
fmt.Println(ms)
sort.Strings(ms)
fmt.Println(ms)
fmt.Println(strings.Join(ms, ""))
sort.Sort(sort.Reverse(sort.StringSlice(ms)))
fmt.Println(ms)
fmt.Println(strings.Join(ms, ""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment