NumericSorter

class NumericSorter(**properties: Any)

Superclasses: Sorter, Object

GtkNumericSorter is a GtkSorter that compares numbers.

To obtain the numbers to compare, this sorter evaluates a Expression.

Constructors

class NumericSorter
classmethod new(expression: Expression | None = None) NumericSorter

Creates a new numeric sorter using the given expression.

Smaller numbers will be sorted first. You can call set_sort_order to change this.

Parameters:

expression – The expression to evaluate

Methods

class NumericSorter
get_expression() Expression | None

Gets the expression that is evaluated to obtain numbers from items.

get_sort_order() SortType

Gets whether this sorter will sort smaller numbers first.

set_expression(expression: Expression | None = None) None

Sets the expression that is evaluated to obtain numbers from items.

Unless an expression is set on self, the sorter will always compare items as invalid.

The expression must have a return type that can be compared numerically, such as int or float.

Parameters:

expression – a GtkExpression

set_sort_order(sort_order: SortType) None

Sets whether to sort smaller numbers before larger ones.

Parameters:

sort_order – whether to sort smaller numbers first

Properties

class NumericSorter
props.expression: Expression

The expression to evaluate on items to get a number to compare with.

props.sort_order: SortType

Whether the sorter will sort smaller numbers first.