Search Sorted 1D Array
- Updated2025-07-30
- 3 minute(s) read
Searches for the first instance of element in sorted 1D array. If the array is not sorted, the results will be incorrect. The connector pane displays the default data types for this polymorphic function.

Inputs/Outputs
sorted 1D array
—
sorted 1D array can be a 1D array of any type.
element
—
element is the value to insert into the array. element must be the same data type as the elements in sorted 1D array.
less function (built-in <)
—
less function is the comparison used to search the array. By default, this is the same comparison the standard Less? function uses. If the array element is a class with a Less Than method that includes two inputs of the same type and a boolean output in the connector pane To specify a different sort order, wire this terminal to one of the following objects:
The comparison function must be symmetric. If a<b is true, b<a is false. If a and b are the same value, both a<b and b<a are false. If the function is not symmetric, the search results will be unpredictable.
found?
—
found? indicates whether the element was found.
nearest index
—
nearest index is the index of the element if found? is TRUE. If found? is FALSE, nearest index is the index where the element would have been in the sorted array. If element is greater than all the elements in the array, nearest index is equal to the size of the array. If element is less than all the elements in the array, nearest index is 0. If you search an empty array, nearest index is 0. |
Examples
Refer to the following example files included with LabVIEW.
- labview\examples\Malleable VIs\Nested Malleable VIs\Malleable VIs - Nested Malleable VIs.lvproj
sorted 1D array
—
element
—
less function (built-in <)
—
, the default changes to use that comparison.
:
:
found?
—
nearest index
—