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

Method SortStableColumn

tensor/table/indexview.go:263–282  ·  view source on GitHub ↗

SortStableColumn sorts the indexes into our Table according to values in given column index, using either ascending or descending order. Only valid for 1-dimensional columns.

(colIndex int, ascending bool)

Source from the content-addressed store, hash-verified

261// given column index, using either ascending or descending order.
262// Only valid for 1-dimensional columns.
263func (ix *IndexView) SortStableColumn(colIndex int, ascending bool) {
264 cl := ix.Table.Columns[colIndex]
265 if cl.IsString() {
266 ix.SortStable(func(et *Table, i, j int) bool {
267 if ascending {
268 return cl.String1D(i) < cl.String1D(j)
269 } else {
270 return cl.String1D(i) > cl.String1D(j)
271 }
272 })
273 } else {
274 ix.SortStable(func(et *Table, i, j int) bool {
275 if ascending {
276 return cl.Float1D(i) < cl.Float1D(j)
277 } else {
278 return cl.Float1D(i) > cl.Float1D(j)
279 }
280 })
281 }
282}
283
284// SortStableColumnNames sorts the indexes into our Table according to values in
285// given column names, using either ascending or descending order.

Callers 1

SortStableColumnNameMethod · 0.95

Calls 4

SortStableMethod · 0.95
IsStringMethod · 0.65
String1DMethod · 0.65
Float1DMethod · 0.65

Tested by

no test coverage detected