SortOrder sorts the splits according to the given ordering of index levels which can be a subset as well
(order []int)
| 179 | // SortOrder sorts the splits according to the given ordering of index levels |
| 180 | // which can be a subset as well |
| 181 | func (spl *Splits) SortOrder(order []int) error { |
| 182 | if len(order) == 0 || len(order) > len(spl.Levels) { |
| 183 | return fmt.Errorf("table.Splits SortOrder: order length == 0 or > Levels") |
| 184 | } |
| 185 | spl.Sort(func(sl *Splits, i, j int) bool { |
| 186 | vli := sl.Values[i] |
| 187 | vlj := sl.Values[j] |
| 188 | for k := range order { |
| 189 | if vli[order[k]] < vlj[order[k]] { |
| 190 | return true |
| 191 | } else if vli[order[k]] > vlj[order[k]] { |
| 192 | return false |
| 193 | } // fallthrough |
| 194 | } |
| 195 | return false |
| 196 | }) |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | // ReorderLevels re-orders the index levels according to the given new ordering indexes |
| 201 | // e.g., []int{1,0} will move the current level 0 to level 1, and 1 to level 0 |
no test coverage detected