GO語言"sort"包中"Strings"函數的用法及代碼示例。
用法:
func Strings(x []string)
Strings 按升序對字符串切片進行排序。
例子:
package main
import (
"fmt"
"sort"
)
func main() {
s := []string{"Go", "Bravo", "Gopher", "Alpha", "Grin", "Delta"}
sort.Strings(s)
fmt.Println(s)
}
輸出:
[Alpha Bravo Delta Go Gopher Grin]
相關用法
- GO Stringer用法及代碼示例
- GO StripPrefix用法及代碼示例
- GO StreamWriter用法及代碼示例
- GO StructTag.Lookup用法及代碼示例
- GO StructTag用法及代碼示例
- GO StructOf用法及代碼示例
- GO StreamReader用法及代碼示例
- GO Stmt用法及代碼示例
- GO Stmt.QueryRowContext用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO Split用法及代碼示例
- GO Server.Shutdown用法及代碼示例
- GO Slice用法及代碼示例
- GO SplitAfter用法及代碼示例
- GO Sum256用法及代碼示例
- GO SectionReader用法及代碼示例
- GO Sin用法及代碼示例
- GO Sprintf用法及代碼示例
- GO SendMail用法及代碼示例
- GO Sprint用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Strings。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。