# SortExpression

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/binding/struct-sortexpression/

**struct** · [`ferroui-dynamic-data`](/docs/0.5.0/api/ferroui-dynamic-data/) · v0.5.0

```rust
struct SortExpression<T>
```

One key of a sort: a value read from each item, and the direction (`SortExpression<T>`).

Deviation (DEVIATIONS.md, DynamicData): upstream holds the getter `Func<T, IComparable>`; Rust
has no common type of the values of different getters, so the expression is held as the
comparison of the values it reads. The values need `PartialOrd`; `Option` puts `None` first,
as upstream puts `null` first, and two values without an order (a `NaN`) compare as equal.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/sort_expression_comparer.rs#L15)

## Members

- [`new`](#function-new)
- [`ascending`](#function-ascending)
- [`direction`](#function-direction)
- [`compare_values`](#function-compare_values)

<a id="function-new"></a>

### new

```rust
fn new<V: PartialOrd + 'static>(expression: impl Fn(&T) -> V + 'static, direction: SortDirection) -> Self
```

The key `expression` in `direction` (`SortExpression(Func<T, IComparable>, SortDirection)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/sort_expression_comparer.rs#L34)

<a id="function-ascending"></a>

### ascending

```rust
fn ascending<V: PartialOrd + 'static>(expression: impl Fn(&T) -> V + 'static) -> Self
```

The key `expression`, ascending (`SortExpression(Func<T, IComparable>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/sort_expression_comparer.rs#L39)

<a id="function-direction"></a>

### direction

```rust
fn direction(self: &Self) -> SortDirection
```

The direction (`Direction`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/sort_expression_comparer.rs#L46)

<a id="function-compare_values"></a>

### compare_values

```rust
fn compare_values(self: &Self, x: &T, y: &T) -> Ordering
```

The comparison of the values that the expression reads from `x` and `y`, ascending
(`Expression(x).CompareTo(Expression(y))`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/sort_expression_comparer.rs#L52)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`
- `Debug`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
