[Go] 정렬
Updated:
예제
- 코드
package main import ( "fmt" "sort" ) func main() { i := []int{1, 3, 2} println(sort.IntsAreSorted(i)) fmt.Println(i) sort.Ints(i) println(sort.IntsAreSorted(i)) fmt.Println(i) println("\n------\n") s := []string{"c", "a", "b"} println(sort.StringsAreSorted(s)) fmt.Println(s) sort.Strings(s) println(sort.StringsAreSorted(s)) fmt.Println(s) }
- 실행 결과
false [1 3 2] true [1 2 3] ------ false [c a b] true [a b c]