> For the complete documentation index, see [llms.txt](https://docs.interestprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.interestprotocol.com/overview/deprecated/sui-tears/utils/comparator.md).

# Comparator

A library to compare structs. BCS uses little-endian encoding for all integer types, so results might be unexpected.

### <mark style="color:blue;">**Result**</mark>

```rust
  struct Result has drop {
    inner: u8,
  }
```

* **inner** - It will hold one of the following values: {SMALLER}, {EQUAL} or {GREATER}.

## Interface

### <mark style="color:blue;">eq</mark>

**It checks if the `result` of {compare} is `EQUAL`.**

```rust
public fun eq(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `EQUAL`

### <mark style="color:blue;">lt</mark>

**It checks if the `result` of {compare} is `SMALLER`.**

```rust
public fun lt(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER`

### <mark style="color:blue;">gt</mark>

**It checks if the `result` of {compare} is `GREATER`.**

```rust
public fun gt(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `GREATER`

### <mark style="color:blue;">lte</mark>

**It checks if the `result` of {compare} is `SMALLER` or `EQUAL`.**

```rust
public fun lte(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER` or `EQUAL`.

### <mark style="color:blue;">gte</mark>

**It checks if the `result` of {compare} is `SMALLER` or `EQUAL`.**

```rust
public fun gte(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER` or `EQUAL`.

### <mark style="color:blue;">compare</mark>

**Compares two structs of type `T`. Performs a comparison of two types after BCS serialization.**

```rust
public fun compare<T>(left: &T, right: &T): Result
```

* **@param left:** A struct of type `T`.
* **@param right:** A struct of type `T`.
* **@return Result.** A struct that contains the following values: {SMALLER}, {EQUAL} or {GREATER}.

### <mark style="color:blue;">compare\_u8\_vector</mark>

**Compares two bytes.**

```rust
public fun compare_u8_vector(left: vector<u8>, right: vector<u8>): Result
```

* **@param left:** A set of bytes.
* **@param right:** A set of bytes.
* **@return Result.** A struct that contains the following values: {SMALLER}, {EQUAL} or {GREATER}.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.interestprotocol.com/overview/deprecated/sui-tears/utils/comparator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
