Skip to content

Commit d2c3d84

Browse files
committed
Move sort default
1 parent 5fdcbdf commit d2c3d84

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/indexer/struct.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,27 @@ type FilterParams struct {
3535
Errors []error
3636
Enabled bool
3737
}
38+
39+
func (ji JoinerIndex) Len() int {
40+
return len(ji)
41+
}
42+
43+
func (ji JoinerIndex) Less(i, j int) bool {
44+
switch ji[i].SortIndex.(type) {
45+
case float32, float64,
46+
int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
47+
if ji[i].SortIndex == ji[j].SortIndex {
48+
return ji[i].Path > ji[j].Path
49+
}
50+
return ut.ToFloat(ji[i].SortIndex) < ut.ToFloat(ji[j].SortIndex)
51+
default:
52+
if ji[i].SortIndex.(string) == ji[j].SortIndex.(string) {
53+
return ji[i].Path > ji[j].Path
54+
}
55+
return ji[i].SortIndex.(string) < ji[j].SortIndex.(string)
56+
}
57+
}
58+
59+
func (ji JoinerIndex) Swap(i, j int) {
60+
ji[i], ji[j] = ji[j], ji[i]
61+
}

0 commit comments

Comments
 (0)