2 Star 1 Fork 0

简单/gostl

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 552 Bytes
一键复制 编辑 原始数据 按行查看 历史
简单 提交于 2023-01-03 19:01 +08:00 . jhl
package main
import (
"fmt"
"gitee.com/jianhaolin/gostl/algorithm/sort"
"gitee.com/jianhaolin/gostl/ds/slice"
"gitee.com/jianhaolin/gostl/utils/comparator"
)
func main() {
a := make([]int, 0)
a = append(a, 2)
a = append(a, 1)
a = append(a, 3)
fmt.Printf("%v\n", a)
wa := slice.NewSliceWrapper(a)
// sort in ascending
sort.Sort[int](wa.Begin(), wa.End(), comparator.IntComparator)
fmt.Printf("%v\n", a)
// sort in descending
sort.Sort[int](wa.Begin(), wa.End(), comparator.Reverse(comparator.IntComparator))
fmt.Printf("%v\n", a)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jianhaolin/gostl.git
git@gitee.com:jianhaolin/gostl.git
jianhaolin
gostl
gostl
v1.3.27

搜索帮助