diff options
author | Andinus <andinus@nand.sh> | 2020-04-06 22:10:32 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-06 22:10:32 +0530 |
commit | 0121a30a7d0fc67f54dabc56b0b4aa030ac3dac4 (patch) | |
tree | 02fd9f7d984a1db7a0d3b6cf0cd24c8a01a6ec84 /lexical/slowsort.go | |
parent | 2e4e8910eb431d10340a29fa797cd0fc8fd4e2db (diff) | |
download | grus-0121a30a7d0fc67f54dabc56b0b4aa030ac3dac4.tar.gz |
Add package lexical
Diffstat (limited to 'lexical/slowsort.go')
-rw-r--r-- | lexical/slowsort.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lexical/slowsort.go b/lexical/slowsort.go new file mode 100644 index 0000000..79f0e62 --- /dev/null +++ b/lexical/slowsort.go @@ -0,0 +1,17 @@ +package lexical + +import ( + "sort" + "strings" +) + +// SlowSort returns string in lexical order. This function is slower +// than Lexical. +func SlowSort(word string) (sorted string) { + // Convert word to a slice, sort the slice. + t := strings.Split(word, "") + sort.Strings(t) + + sorted = strings.Join(t, "") + return +} |