xsort

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xsort is the sorter of D2's own code: Func, StableFunc and Ordered are slices.SortFunc, slices.SortStableFunc and slices.Sort.

In this, the default build, they call those functions directly, so native programs keep the specialized, reflection-free sorters. In WebAssembly builds (build tag tinygo; xsort_small selects the same code natively for tests) they run the non-generic sorters of package sort instead, so that the module carries one copy of each algorithm rather than one per element type. Both packages generate their sorters from one template (sort/gen_sort_variants.go), so the two variants make the same comparisons and swaps and leave the same order, ties included. xsort_small_test.go checks that.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Func

func Func[S ~[]E, E any](s S, compare func(a, b E) int)

Func is slices.SortFunc.

func Ordered

func Ordered[S ~[]E, E cmp.Ordered](s S)

Ordered is slices.Sort.

func StableFunc

func StableFunc[S ~[]E, E any](s S, compare func(a, b E) int)

StableFunc is slices.SortStableFunc.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL