MCPcopy Create free account
hub / github.com/datasweet/datatable / Sort

Method Sort

sort.go:47–70  ·  view source on GitHub ↗

Sort the table

(by ...SortBy)

Source from the content-addressed store, hash-verified

45
46// Sort the table
47func (t *DataTable) Sort(by ...SortBy) *DataTable {
48 cpy := t.Copy()
49
50 if len(by) == 0 {
51 return cpy
52 }
53
54 for i := range by {
55 b := &by[i]
56 // Check if column exists
57 b.index = t.ColumnIndex(b.Column)
58 if b.index < 0 {
59 return cpy
60 }
61 }
62
63 srt := &sorter{
64 t: cpy,
65 by: by,
66 }
67
68 sort.Sort(srt)
69 return cpy
70}

Callers 3

TestSortFunction · 0.80
SortAscMethod · 0.80
SortDescMethod · 0.80

Calls 2

CopyMethod · 0.95
ColumnIndexMethod · 0.95

Tested by 1

TestSortFunction · 0.64