natcmp

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 4 Imported by: 1

README

natcmp provides natural sort comparisons for Go. suitable for use with slices.SortFunc since go1.21

$ go get go.senan.xyz/natcmp

godoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string) int

Compare performs a natural comparison between two strings, a and b, suitable for use with slices.SortFunc by returning an integer comparing their natural order.

Natural sorting orders numeric substrings in ascending order and string substrings using lexicographical order. See:

The result is 0 if a == b, -1 if a < b, and +1 if a > b.

Types

This section is empty.

Jump to

Keyboard shortcuts

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