GLib.ThreadPool.set_sort_function

### Method

# GLib ThreadPoolset_sort_function

since: 2.10

#### Declaration [src]

    void
    g_thread_pool_set_sort_function (
      GThreadPool* pool,
      GCompareDataFunc func,
      gpointer user_data
    )

#### Description [src]

Sets the function used to sort the list of tasks. This allows the tasks to be processed by a priority determined by `func`, and not just in the order in which they were added to the pool.

Note, if the maximum number of threads is more than 1, the order that threads are executed cannot be guaranteed 100%. Threads are scheduled by the operating system and are executed at random. It cannot be assumed that threads are executed in the order they are created.

Available since: 2.10

This method is not directly available to language bindings.

#### Parameters

`func`

  Type: `GCompareDataFunc`

  The `GCompareDataFunc` used to sort the list of tasks. This function is passed two tasks. It should return 0 if the order in which they are handled does not matter, a negative value if the first task should be processed before the second or a positive value if the second task should be processed first.

`user_data`

  Type: `gpointer`

  User data passed to `func`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.