### Function

# GLib List insert_sorted_with_data

since: 2.10

#### Declaration [src]

    GList*
    g_list_insert_sorted_with_data (
      GList* list,
      gpointer data,
      GCompareDataFunc func,
      gpointer user_data
    )

#### Description [src]

Inserts a new element into the list, using the given comparison function to determine its position.

If you are adding many new elements to a list, and the number of new elements is much larger than the length of the list, use `g_list_prepend()` to add the new items and sort the list afterwards with g_list_sort().

Available since: 2.10

This function is not directly available to language bindings.

#### Parameters

`list`

  Type: A list of `gpointer`

  A pointer to a `GList`, this must point to the top of the already sorted list.

  The data is owned by the caller of the function.

`data`

  Type: `gpointer`

  The data for the new element.

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

`func`

  Type: `GCompareDataFunc`

  The function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.

`user_data`

  Type: `gpointer`

  User data to pass to comparison function.

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

#### Return value

Type: A list of `gpointer`

The (possibly changed) start of the `GList`.

The data is owned by the called function.