---
title: "ClikaRT::ops::searchsorted"
sidebar_label: "searchsorted"
description: "Insertion points of values into a sorted sequence. For each value, the index in sorted_sequence's last axis where it would insert to keep the order: right == false gives the leftmost admissible slot,…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## searchsorted() {#searchsorted}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`searchsorted`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `sorted_sequence`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `values`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `out_int32` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `right` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<bool>` `side` `=` `std::nullopt`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `sorter` `=` `{}`<br />
)

</div>

Insertion points of `values` into a sorted sequence.

For each value, the index in `sorted_sequence`'s last axis where it would insert to keep the order: `right == false` gives the leftmost admissible slot, `true` the rightmost. `side`, when present, must AGREE with `right` (it is the same switch under its string-API name); `sorter` supplies indices that sort an unsorted sequence.

**Parameters**

- `sorted_sequence`: the sorted haystack (last-axis sorted).
- `values`: the needles; output mirrors this shape.
- `out_int32`: emit `Int32` indices instead of `Int64`.
- `right`: insertion side for ties; default false (left).
- `side`: optional string-API twin of `right`; a present value that contradicts `right` is an error.
- `sorter`: optional `Int64`/`Int32` indices sorting the sequence.

**Returns:** integer insertion indices, shaped like `values`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `side` contradicts `right` or the operand shapes are incompatible.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4756

</div>
