MCPcopy Create free account
hub / github.com/mmcgrana/gobyexample / main

Function main

examples/sorting/sorting.go:12–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func main() {
13
14 // Sorting functions are generic, and work for any
15 // _ordered_ built-in type. For a list of ordered
16 // types, see [cmp.Ordered](https://pkg.go.dev/cmp#Ordered).
17 strs := []string{"c", "a", "b"}
18 slices.Sort(strs)
19 fmt.Println("Strings:", strs)
20
21 // An example of sorting `int`s.
22 ints := []int{7, 2, 4}
23 slices.Sort(ints)
24 fmt.Println("Ints: ", ints)
25
26 // We can also use the `slices` package to check if
27 // a slice is already in sorted order.
28 s := slices.IsSorted(ints)
29 fmt.Println("Sorted: ", s)
30}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected