summaryrefslogtreecommitdiff
path: root/strings/strings.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2018-07-18 21:35:33 -0400
committerDave Henderson <dhenderson@gmail.com>2018-07-18 21:35:33 -0400
commitc56dc624778fc3f9695a712c02c8b306da0c88b2 (patch)
treead4c9ac281511680014a465654ace05f3759ba78 /strings/strings.go
parent458c19fba9b7183bf60504af6005c7fc82fc3815 (diff)
Adding new strings.Sort function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'strings/strings.go')
-rw-r--r--strings/strings.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/strings/strings.go b/strings/strings.go
index 3b90c83e..6d89def7 100644
--- a/strings/strings.go
+++ b/strings/strings.go
@@ -1,6 +1,9 @@
package strings
-import "strings"
+import (
+ "sort"
+ "strings"
+)
// Indent - indent each line of the string with the given indent string
func Indent(width int, indent, s string) string {
@@ -33,3 +36,10 @@ func Trunc(length int, s string) string {
}
return s[0:length]
}
+
+// Sort - return an alphanumerically-sorted list of strings
+func Sort(list []string) []string {
+ sorted := sort.StringSlice(list)
+ sorted.Sort()
+ return sorted
+}