MCPcopy Create free account
hub / github.com/cogentcore/core / SortOrder

Method SortOrder

tensor/table/splits.go:181–198  ·  view source on GitHub ↗

SortOrder sorts the splits according to the given ordering of index levels which can be a subset as well

(order []int)

Source from the content-addressed store, hash-verified

179// SortOrder sorts the splits according to the given ordering of index levels
180// which can be a subset as well
181func (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

Callers 1

ExtractLevelsMethod · 0.80

Calls 2

SortMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected