naturalsort

package
v0.2.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2015 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

README

naturalsort

A simple natural sorter for Go Strings ##Usage Implements the sort.Interface

called by sort.Sort(NaturalSort([]string) ###Example SampleStringArray := []string{"z24", "z2", "z15", "z1", "z3", "z20", "z5", "z11", "z 21", "z22"} sort.Sort(NaturalSort(SampleStringArray)) ##Needless Description Inspired by Jeff Atwood's seminal blog post and structured similarly to Ian Griffiths' C# implementation. This uses a regex to split the numeric and non-numeric portions of the string into a chunky array. Next, the left and right sides' chunks are compared either by string comparrison (if either is a non-numeric chunk), or by integer (if both chunks are numeric)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NaturalSort

type NaturalSort []string

func (NaturalSort) Len

func (s NaturalSort) Len() int

func (NaturalSort) Less

func (s NaturalSort) Less(i, j int) bool

func (NaturalSort) Swap

func (s NaturalSort) Swap(i, j int)

Jump to

Keyboard shortcuts

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