> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::traits::PartialOrd

Trait for comparing types that form a
partialorder.
The `lt`, `le`, `gt`, and `ge` methods of this trait can be called using the \`\`, and
`>=` operators, respectively.
PartialOrd is not derivable, but can be implemented manually

## Signature

```rust theme={null}
pub trait PartialOrd
```

# Implementing `PartialOrd`

Here's how to implement `PartialOrd` for a custom type. This example implements
comparison operations for a 2D point where points are compared based on their
squared Euclidean distance from the origin (0,0):

```rust theme={null}
#[derive(Copy, Drop, PartialEq)]
struct Point {
    x: u32,
    y: u32,
}

impl PointPartialOrd of PartialOrd {
    fn lt(lhs: Point, rhs: Point) -> bool {
        let lhs_dist = lhs.x * lhs.x + lhs.y * lhs.y;
        let rhs_dist = rhs.x * rhs.x + rhs.y * rhs.y;
        lhs_dist  p1);
assert!(p2 >= p1);
```

Note that only the `lt` method needs to be implemented. The other comparison
operations (`le`, `gt`, `ge`) are automatically derived from `lt`. However,
you can override them for better performance if needed.

## Trait functions

### lt

Tests less than (for `self` and `other`) and is used by the \`(lhs: T, rhs: T) -> bool

```


### ge



Tests less than or equal to (for `self` and `other`) and is used by the
`(lhs: T, rhs: T) -> bool
```

### gt

Tests greater than (for `self` and `other`) and is used by the `>`
operator.

#### Signature

```rust theme={null}
fn gt(lhs: T, rhs: T) -> bool
```

#### Examples

```rust theme={null}
assert_eq!(1 > 1, false);
assert_eq!(1 > 2, false);
assert_eq!(2 > 1, true);
```

### le

Tests greater than or equal to (for `self` and `other`) and is used by
the `>=` operator.

#### Signature

```rust theme={null}
fn le(lhs: T, rhs: T) -> bool
```

#### Examples

```rust theme={null}
assert_eq!(1 >= 1, true);
assert_eq!(1 >= 2, false);
assert_eq!(2 >= 1, true);
```
