GLib.Sequence.insert_sorted

### Method

# GLib Sequenceinsert_sorted

since: 2.14

#### Declaration [src]

    GSequenceIter*
    g_sequence_insert_sorted (
      GSequence* seq,
      gpointer data,
      GCompareDataFunc cmp_func,
      gpointer cmp_data
    )

#### Description [src]

Inserts `data` into `seq` using `cmp_func` to determine the new position. The sequence must already be sorted according to `cmp_func`; otherwise the new position of `data` is undefined.

`cmp_func` is called with two items of the `seq`, and `cmp_data`. It should return 0 if the items are equal, a negative value if the first item comes before the second, and a positive value if the second item comes before the first.

Note that when adding a large amount of data to a `GSequence`, it is more efficient to do unsorted insertions and then call `g_sequence_sort()` or g_sequence_sort_iter().

Available since: 2.14

#### Parameters

`data`

  Type: `gpointer`

  The data to insert.

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

`cmp_func`

  Type: `GCompareDataFunc`

  The function used to compare items in the sequence.

`cmp_data`

  Type: `gpointer`

  User data passed to `cmp_func`.

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

#### Return value

Type: `GSequenceIter`

A `GSequenceIter` pointing to the new item.

The returned data is owned by the instance.