---
name: "bson_compare"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_compare"
---

# bson\_compare(3)

## SYNOPSIS

```
int
bson_compare (const bson_t *bson, const bson_t *other);
```

## PARAMETERS

- •

  **bson**: A *bson\_t*.

- •

  **other**: A *bson\_t*.

## DESCRIPTION

The *bson\_compare()* function shall compare two bson documents for equality.

This can be useful in conjunction with \_qsort()\_.

If equal, 0 is returned.

**TIP:**

This function uses \_memcmp()\_ internally, so the semantics are the same.

## RETURNS

less than zero, zero, or greater than zero in **qsort()** style.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
