func (c *JSONCollator) Collate(key1, key2 interface{}) int {
	type1 := collationType(key1)
	type2 := collationType(key2)
	if type1 != type2 {
		return compareTokens(type1, type2)
	}
	switch type1 {
	case kNull, kFalse, kTrue:
		return 0
	case kNumber:
		return compareFloats(collationToFloat64(key1), collationToFloat64(key2))
	case kString:
		return c.compareStrings(key1.(string), key2.(string))
	case kArray:
		array1 := key1.([]interface{})
		array2 := key2.([]interface{})
		for i, item1 := range array1 {
			if i >= len(array2) {
				return 1
			}
			if cmp := c.Collate(item1, array2[i]); cmp != 0 {
				return cmp
			}
		}
		return compareInts(len(array1), len(array2))
	case kObject:
		return 0  
	}
	panic("bogus collationType")
}
CouchDB-compatible collation/comparison of JSON values.
See: http://wiki.apache.org/couchdb/View_collation#Collation_Specification
package walrus
import (
	"encoding/json"
	"fmt"
	"golang.org/x/text/collate"
	"golang.org/x/text/language"
)
type JSONCollator struct {
	stringCollator *collate.Collator
}
func defaultLocale() language.Tag {
	l, e := language.Parse("icu")
	if e != nil {
		return language.Und
	}
	return l
}
func CollateJSON(key1, key2 interface{}) int {
	var collator JSONCollator
	return collator.Collate(key1, key2)
}
func (c *JSONCollator) Clear() {
	c.stringCollator = nil
}