# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
