MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Timsort

Function Timsort

sort/timsort.go:13–18  ·  view source on GitHub ↗

Timsort is a simple generic implementation of Timsort algorithm.

(data []T)

Source from the content-addressed store, hash-verified

11
12// Timsort is a simple generic implementation of Timsort algorithm.
13func Timsort[T constraints.Ordered](data []T) []T {
14 runSize := calculateRunSize(len(data))
15 insertionSortRuns(data, runSize)
16 mergeRuns(data, runSize)
17 return data
18}
19
20// calculateRunSize returns a run size parameter that is further used
21// to slice the data slice.

Callers

nothing calls this directly

Calls 3

calculateRunSizeFunction · 0.85
insertionSortRunsFunction · 0.85
mergeRunsFunction · 0.85

Tested by

no test coverage detected