-
Notifications
You must be signed in to change notification settings - Fork 3
/
sorting.go
37 lines (35 loc) · 1015 Bytes
/
sorting.go
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
package youtube
import "sort"
//SortBy sorts videos by some params
func SortBy(vs []VideoStatistics, sortingColumn string) {
switch sortingColumn {
case "total-reaction":
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].TotalReaction > vs[j].TotalReaction
})
case "positive-interest":
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].PositiveInterestingness > vs[j].PositiveInterestingness
})
case "pnc":
fallthrough
case "positive-negative-coefficient":
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].PositiveNegativeCoefficient > vs[j].PositiveNegativeCoefficient
})
case "global-buzz-index":
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].GlobalBuzzIndex > vs[j].GlobalBuzzIndex
})
case "likes":
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].LikeCount > vs[j].LikeCount
})
case "total-interest":
fallthrough
default:
sort.Slice(vs[:], func(i, j int) bool {
return vs[i].TotalInterestingness > vs[j].TotalInterestingness
})
}
}