C# · Sorting and Sets

Sorting and Sets

6.0.0-rc.1 · 91a27bdd

These take a caller-provided result buffer and return the count; allocating convenience overloads also exist.

long[] order = new long[items.Count];
int sorted = Sz.ArgSort(items, order, top: 10, uncased: true); // cf. Array.Sort + StringComparer.Ordinal

Span<long> lineOrder = stackalloc long[lineCount];
Sz.ArgSort(buffer, starts, lengths, lineOrder); // sort one buffer's segments without a byte[][]

long[] firstPositions = new long[Math.Min(left.Count, right.Count)];
long[] secondPositions = new long[firstPositions.Length];
int matches = Sz.Intersect(left, right, firstPositions, secondPositions); // matching index pairs

A failed native call throws StatusException, whose Status is the C sz_status_t code and StatusName its enumerator name.