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

Method SortStableColumnNames

tensor/table/indexview.go:288–304  ·  view source on GitHub ↗

SortStableColumnNames 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

286// Only valid for 1-dimensional columns.
287// Returns error if column name not found.
288func (ix *IndexView) SortStableColumnNames(columns []string, ascending bool) error {
289 nc := len(columns)
290 if nc == 0 {
291 return fmt.Errorf("table.IndexView.SortStableColumnNames: no column names provided")
292 }
293 cis := make([]int, nc)
294 for i, cn := range columns {
295 ci, err := ix.Table.ColumnIndexTry(cn)
296 if err != nil {
297 log.Println(err)
298 return err
299 }
300 cis[i] = ci
301 }
302 ix.SortStableColumns(cis, ascending)
303 return nil
304}
305
306// SortStableColumns sorts the indexes into our Table according to values in
307// given list of column indexes, using either ascending or descending order for

Callers 1

genPlotXYMethod · 0.80

Calls 4

SortStableColumnsMethod · 0.95
ColumnIndexTryMethod · 0.80
PrintlnMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected