I was sorting two structs this way, before
type TwoSlices struct {
main_slice []float64
other_slice []string
}
type SortByOther TwoSlices
func (sbo SortByOther) Len() int {
return len(sbo.main_slice)
}
func (sbo SortByOther) Swap(i, j int) {
sbo.main_slice[i], sbo.main_slice[j] = sbo.main_slice[j], sbo.main_slice[i]
sbo.other_slice[i], sbo.other_slice[j] = sbo.other_slice[j], sbo.other_slice[i]
}
func (sbo SortByOther) Less(i, j int) bool {
return sbo.other_slice[i] < sbo.other_slice[j]
}
var Leaderboard = make([]string, 1)
var Leaderboard_WPM = make([]float64, 1)
Leaderboard = ...
Leaderboard_WPM = ...
var my_two_slices = TwoSlices{main_slice: Leaderboard_WPM, other_slice: Leaderboard}
sort.Sort(SortByOther(my_two_slices))```
at first glance, it worked, but now it failed to sort and just kept everything the same