The typical way to sort in C is using qsort(). Therefore, Libbson provides a qsort() compatible callback function named bson_oid_compare(). It returns lessthan1, greaterthan1, or 0 depending on the equality of two bson_oid_t structures.

If you need to parse may bson_oid_t in a tight loop and can guarantee the data is safe, you might consider using the inline variant. It will be inlined into your code and reduce the need for a foreign function call.