sqlite
sqlite copied to clipboard
Add custom collation functions
// CreateCollation registers a Go function as a SQLite collation function.
//
// These function are used with the COLLATE operator to implement custom sorting in queries.
//
// The xCompare function must return an integer that is negative, zero, or positive if the first
// string is less than, equal to, or greater than the second, respectively. The function must
// always return the same result for the same inputs and must be commutative.
//
// These are the same properties as strings.Compare().
//
// https://sqlite.org/datatype3.html#collation
// https://sqlite.org/c3ref/create_collation.html
func (conn *Conn) CreateCollation(name string, xCompare func(string, string) int) error {