collate

package
v4.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package collate provides (near) CouchDB-compatible collation functions.

The collation order provided by this package differs slightly from that described by the CouchDB documentation. In particular:

  • The Unicode UCI algorithm supported natively by Go sorts the backtick (`) and caret (^) after other symbols, not before.
  • Because Go's maps are unordered, this implementation does not honor the order of object key members when collating. That is to say, the object `{b:2,a:1}` is treated as equivalent to `{a:1,b:2}` for collation purposes. This is tracked in issue #952. Please leave a comment there if this is affecting you.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareObject

func CompareObject(a, b interface{}) int

CompareObject compares two unmarshaled JSON objects. The function will panic if it encounters an unexpected type. The comparison is performed recursively, with keys sorted before comparison. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func CompareString

func CompareString(a, b string) int

CompareString returns an integer comparing the two strings. The result will be 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