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

Method SortColumnNames

tensor/table/indexview.go:174–190  ·  view source on GitHub ↗

SortColumnNames sorts the indexes into our Table according to values in given column names, using either ascending or descending order. Only valid for 1-dimensional columns. Returns error if column name not found.

(columns []string, ascending bool)

Source from the content-addressed store, hash-verified

172// Only valid for 1-dimensional columns.
173// Returns error if column name not found.
174func (ix *IndexView) SortColumnNames(columns []string, ascending bool) error {
175 nc := len(columns)
176 if nc == 0 {
177 return fmt.Errorf("table.IndexView.SortColumnNames: no column names provided")
178 }
179 cis := make([]int, nc)
180 for i, cn := range columns {
181 ci, err := ix.Table.ColumnIndexTry(cn)
182 if err != nil {
183 log.Println(err)
184 return err
185 }
186 cis[i] = ci
187 }
188 ix.SortColumns(cis, ascending)
189 return nil
190}
191
192// SortColumns sorts the indexes into our Table according to values in
193// given list of column indexes, using either ascending or descending order for

Callers 1

genPlotBarMethod · 0.80

Calls 4

SortColumnsMethod · 0.95
ColumnIndexTryMethod · 0.80
PrintlnMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected