MCPcopy Create free account
hub / github.com/brimdata/super / SortStable

Method SortStable

runtime/sam/expr/sort.go:221–231  ·  view source on GitHub ↗

SortStable sorts vals according to c, with equal values in their original order. SortStable allocates more memory than [SortStableReader].

(vals []super.Value)

Source from the content-addressed store, hash-verified

219// SortStable sorts vals according to c, with equal values in their original
220// order. SortStable allocates more memory than [SortStableReader].
221func (c *Comparator) SortStable(vals []super.Value) {
222 tmp := make([]super.Value, len(vals))
223 for i, index := range c.sortStableIndices(vals) {
224 tmp[i] = vals[i]
225 if j := int(index); i < j {
226 vals[i] = vals[j]
227 } else if i > j {
228 vals[i] = tmp[j]
229 }
230 }
231}
232
233// SortStableReader returns a reader for vals sorted according to c, with equal
234// values in their original order.

Callers 2

BenchmarkSortFunction · 0.95
sendMethod · 0.80

Calls 1

sortStableIndicesMethod · 0.95

Tested by 1

BenchmarkSortFunction · 0.76