Documentation
¶
Overview ¶
Package bib contains functions for (English-language) bibliographic sorting of strings.
A bibliographic sort is one that ignores a leading article ("the," "a," "an") and treats leading numbers as if they're spelled out. Characters other than letters and digits are ignored, except that "&" is converted to the spelled-out word "and," and hyphens are converted to spaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Key ¶
Key converts an input string to a bibliographic sort key. It does this by trimming whitespace, converting to lower case, removing leading articles, converting "&" to "and," and hyphens to spaces, converting leading numbers to their spelled-out equivalents (distinguishing between regular ordinals, cardinal numbers, and years), and finally removing all characters other than letters, digits, and whitespace.
func Less ¶
Less tells whether a comes before b in a bibliograhic sort. It does this by calling Key on each string, qv.
func Sort ¶
func Sort(strs []string)
Sort sorts the input slice bibliographically, in place. This is more time-efficient than calling sort.Slice with Less as the comparison function. That would call Key on each string in the slice more than once, on average. Instead, this function computes the keys for all the strings exactly once, then sorts the slice using those keys (using slices.KeyedSort).
Types ¶
This section is empty.