:right-sidebar: True NumericSorter =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: NumericSorter(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Sorter`, :class:`~gi.repository.GObject.Object` ``GtkNumericSorter`` is a ``GtkSorter`` that compares numbers. To obtain the numbers to compare, this sorter evaluates a :obj:`~gi.repository.Gtk.Expression`. Constructors ------------ .. rst-class:: interim-class .. class:: NumericSorter :no-index: .. classmethod:: new(expression: ~gi.repository.Gtk.Expression | None = None) -> ~gi.repository.Gtk.NumericSorter Creates a new numeric sorter using the given ``expression``. Smaller numbers will be sorted first. You can call :obj:`~gi.repository.Gtk.NumericSorter.set_sort_order` to change this. :param expression: The expression to evaluate Methods ------- .. rst-class:: interim-class .. class:: NumericSorter :no-index: .. method:: get_expression() -> ~gi.repository.Gtk.Expression | None Gets the expression that is evaluated to obtain numbers from items. .. method:: get_sort_order() -> ~gi.repository.Gtk.SortType Gets whether this sorter will sort smaller numbers first. .. method:: set_expression(expression: ~gi.repository.Gtk.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 :obj:`int` or :obj:`float`. :param expression: a ``GtkExpression`` .. method:: set_sort_order(sort_order: ~gi.repository.Gtk.SortType) -> None Sets whether to sort smaller numbers before larger ones. :param sort_order: whether to sort smaller numbers first Properties ---------- .. rst-class:: interim-class .. class:: NumericSorter :no-index: .. attribute:: props.expression :type: ~gi.repository.Gtk.Expression The expression to evaluate on items to get a number to compare with. .. attribute:: props.sort_order :type: ~gi.repository.Gtk.SortType Whether the sorter will sort smaller numbers first.