Repository navigation
Expand file tree
/
Copy pathsort.go
More file actions
145 lines (125 loc) · 2.44 KB
/
Copy pathsort.go
File metadata and controls
145 lines (125 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Sortright 2020 slice Author(https://github.com/yudeguang/slice). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/yudeguang/slice.
package slice
import (
"sort"
)
// func Sort(s []interface{}) []interface{} {
// sort.Slice(s, func(i, j int) bool {
// return s[i] < s[j]
// })
// return s
// }
//切片排序
func SortString(s []string) {
sort.Strings(s)
}
//切片排序
func SortInt(s []int) {
sort.Ints(s)
}
//切片排序
func SortInt8(s []int8) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortInt16(s []int16) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortInt32(s []int32) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortInt64(s []int64) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUint(s []uint) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUint8(s []uint8) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUint16(s []uint16) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUint32(s []uint32) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUint64(s []uint64) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortUintptr(s []uintptr) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortFloat32(s []float32) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortFloat64(s []float64) {
sort.Float64s(s)
}
//切片排序
func SortRune(s []rune) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
//切片排序
func SortByte(s []byte) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
// //切片排序
// func SortComplex64(s []complex64) []complex64 {
// sort.Slice(s, func(i, j int) bool {
// return s[i] < s[j]
// })
// return s
// }
// //切片排序
// func SortComplex128(s []complex128) []complex128 {
// sort.Slice(s, func(i, j int) bool {
// return s[i] < s[j]
// })
// return s
// }
////切片排序
// func SortBool(s []bool) {
// sort.Slice(s, func(i, j int) bool {
// return s[i] < s[j]
// })
// }