Gtk.TreeIterCompareFunc
Description: Reference for Gtk.TreeIterCompareFunc

### Function

# GtkTreeIterCompareFunc

#### Declaration

    int
    TreeIterCompareFunc (
      GtkTreeModel* model,
      GtkTreeIter* a,
      GtkTreeIter* b,
      gpointer user_data
    )

#### Description [src]

A GtkTreeIterCompareFunc should return a negative integer, zero, or a positive integer if `a` sorts before `b`, `a` sorts with `b`, or `a` sorts after `b` respectively.

If two iters compare as equal, their order in the sorted model is undefined. In order to ensure that the `GtkTreeSortable` behaves as expected, the GtkTreeIterCompareFunc must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.

For example, if `model` is a product catalogue, then a compare function for the “price” column could be one which returns `price_of(`a`) - price_of(`b`)`.

#### Parameters

`model` | `GtkTreeModel`
| The `GtkTreeModel` the comparison is within.
| The data is owned by the caller of the function.
`a` | `GtkTreeIter`
| A `GtkTreeIter` in `model`.
| The data is owned by the caller of the function.
`b` | `GtkTreeIter`
| Another `GtkTreeIter` in `model`.
| The data is owned by the caller of the function.
`user_data` | `gpointer`
| Data passed when the compare func is assigned e.g. by `gtk_tree_sortable_set_sort_func()`

#### Return value

Returns: | `int`
| A negative integer, zero or a positive integer depending on whether `a` sorts before, with or after `b`.