code: func CompareBinary(left, right BinaryJSON) int {
  	precedence1 := jsonTypePrecedences[left.Type()]
  	precedence2 := jsonTypePrecedences[right.Type()]
  	var cmp int
  	if precedence1 == precedence2 {
  		if precedence1 == jsonTypePrecedences["NULL"] {
  			// for JSON null.
  			cmp = 0
  		}
  		switch left.TypeCode {
  		case TypeCodeLiteral:
  			// false is less than true.
  			cmp = int(right.Value[0]) - int(left.Value[0])
  		case TypeCodeInt64, TypeCodeUint64, TypeCodeFloat64:
  			leftFloat := i64AsFloat64(left.GetInt64(), left.TypeCode)
  			rightFloat := i64AsFloat64(right.GetInt64(), right.TypeCode)
  			cmp = compareFloat64PrecisionLoss(leftFloat, rightFloat)
  		case TypeCodeString:
  			cmp = bytes.Compare(left.GetString(), right.GetString())
  		case TypeCodeArray:
  			leftCount := left.GetElemCount()
  			rightCount := right.GetElemCount()
  			for i := 0; i < leftCount && i < rightCount; i++ {
  				elem1 := left.arrayGetElem(i)
  				elem2 := right.arrayGetElem(i)
  				cmp = CompareBinary(elem1, elem2)
  				if cmp != 0 {
  					return cmp
  				}
  			}
  			cmp = leftCount - rightCount
  		case TypeCodeObject:
  			// only equal is defined on two json objects.
  			// larger and smaller are not defined.
  			cmp = bytes.Compare(left.Value, right.Value)
  		}
  	} else {
  		cmp = precedence1 - precedence2
  	}
  	return cmp
  }
docs: // CompareBinary compares two binary json objects. Returns -1 if left < right,
  // 0 if left == right, else returns 1.