package main

import (
    "fmt"
    "sort"
)

func main() {
    str := []string{"", "", "d", "b","c", }
    sort.Strings(str)
    fmt.Println(str)

    ints := []int{5,4,3,2,1}
    sort.Ints(ints)
    fmt.Println(ints)

    floats := []float64{1.1, 0.4, 9.3, 2.1}
    sort.Float64s(floats)
    fmt.Println(floats)

    uints := []uint8{4,2,1,5,5}
    sort.Slice(uints, func(i, j int) bool {
        return uints[i] < uints[j]
    })
    fmt.Println(uints)
}

 

相关文章:

  • 2022-03-06
  • 2021-08-26
  • 2022-12-23
  • 2022-02-28
  • 2021-09-24
  • 2022-02-04
  • 2021-06-22
  • 2021-12-28
猜你喜欢
  • 2021-08-31
  • 2021-04-11
  • 2021-09-27
  • 2022-01-15
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案