# SortExpressionComparer

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

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

```rust
struct SortExpressionComparer<T>
```

A comparer of items by a list of keys, each ascending or descending
(`SortExpressionComparer<T>`): the first key that differs decides.

It builds as upstream's does, `SortExpressionComparer::ascending(|p: &Person| p.age())
.then_by_ascending(|p| p.name())`, and becomes the comparer that the operators take,
`Rc<dyn Fn(&T, &T) -> Ordering>`, with `comparer` or `into()`.

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

## Members

- [`ascending`](#function-ascending)
- [`descending`](#function-descending)
- [`then_by_ascending`](#function-then_by_ascending)
- [`then_by_descending`](#function-then_by_descending)
- [`comparer`](#function-comparer)
- [`push`](#function-push)
- [`expressions`](#function-expressions)
- [`compare`](#function-compare)

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

### ascending

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

A comparer by `expression`, ascending (`SortExpressionComparer<T>.Ascending`).

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

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

### descending

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

A comparer by `expression`, descending (`SortExpressionComparer<T>.Descending`).

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

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

### then_by_ascending

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

The comparer, then by `expression`, ascending (`ThenByAscending`).

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

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

### then_by_descending

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

The comparer, then by `expression`, descending (`ThenByDescending`).

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

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

### comparer

```rust
fn comparer(self: &Self) -> Rc<dyn Fn(&T, &T) -> Ordering>
```

The comparer as the function that the operators take (`IComparer<T>`).

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

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

### push

```rust
fn push(self: &mut Self, expression: SortExpression<T>)
```

Adds a key (`Add`, of the list upstream's comparer is).

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

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

### expressions

```rust
fn expressions(self: &Self) -> &[SortExpression<T>]
```

The keys, in order.

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

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

### compare

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

Compares `x` and `y` by the keys in order (`Compare`).

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

## 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`
- `Default`
- `Debug`
- `From<SortExpressionComparer<T>>`

## Availability

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