std.sort

QuickSort-Implementierung für int64-Arrays mit Median-of-Three-Pivotisierung (verhindert Worst-Case bei sortierten Eingaben) und Insertion-Sort-Fallback für kleine Teilfolgen. Die Sortierung erfolgt in-place ohne zusätzliche Speicherallokation.

Einsatzbereiche: Sortierung von Messwerten, Indexstrukturen, Vorbereitung für std.stats (Median-Berechnung), Binärsuche-Vorbedingung.

Autor: Andreas Röne
Copyright: 2024-2025 Andreas Röne


Funktionen

Signatur Sichtbarkeit Beschreibung
SortInt64(arr: int64, len: int64): void pub Sortiert int64-Array in-place aufsteigend
SortSwap(arr: int64, i: int64, j: int64): void priv Tauscht zwei Elemente im Array
SortGet(arr: int64, idx: int64): int64 priv Liest Element an Index aus Array
MedianOfThree(arr: int64, low: int64, mid: int64, high: int64): void priv Bestimmt Pivot per Median-of-Three
Partition(arr: int64, low: int64, high: int64): int64 priv Partitioniert Teilarray um Pivot
InsertionSort(arr: int64, low: int64, high: int64): void priv Sortiert kleines Teilarray per Insertion-Sort
QuickSortInternal(arr: int64, low: int64, high: int64): void priv Rekursiver QuickSort-Kern