sortorder

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 0 Imported by: 771

README

sortorder PkgGoDev

import "github.com/fvbommel/sortorder"

Sort orders and comparison functions.

Case-insensitive sort orders are in the casefolded sub-package because it pulls in the Unicode tables in the standard library, which can add significantly to the size of binaries.

Documentation

Overview

Package sortorder implements sort orders and comparison functions.

Currently, it only implements so-called "natural order", where integers embedded in strings are compared by value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NaturalLess

func NaturalLess(str1, str2 string) bool

NaturalLess compares two strings using natural ordering. This means that e.g. "abc2" < "abc12".

Non-digit sequences and numbers are compared separately. The former are compared bytewise, while digits are compared numerically (except that the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")

Limitation: only ASCII digits (0-9) are considered.

Types

type Natural

type Natural []string

Natural implements sort.Interface to sort strings in natural order. This means that e.g. "abc2" < "abc12".

Non-digit sequences and numbers are compared separately. The former are compared bytewise, while digits are compared numerically (except that the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")

Limitation: only ASCII digits (0-9) are considered.

func (Natural) Len

func (n Natural) Len() int

func (Natural) Less

func (n Natural) Less(i, j int) bool

func (Natural) Swap

func (n Natural) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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