Inserts element into sorted array in while maintaining sorted order. If the array is not sorted, the element may be inserted at the wrong location. The connector pane displays the default data types for this polymorphic function.


icon

Inputs/Outputs

  • c1dLess_Comparablelvclass.png sorted array in

    sorted array in can be a 1D array of any type.

  • cLess_Comparablelvclass.png element

    element is the value to insert into the array. element must be the same data type as the elements in sorted array in.

  • cLess_Functorlvclass.png 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 , the default changes to use that comparison.

    To specify a different sort order, wire this terminal to one of the following objects:

    • A class that defines a Less Than method with the following connector pane configuration :
      • A functor input in the top-left. A functor is a class that defines an operation on a data type.
      • Two inputs of the same data type as the array elements.
      • A boolean output.
    • A VI refnum with the following connector pane configuration :
      • Two inputs of the same data type as the array elements.
      • A boolean output.

    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.

  • i1dLess_Comparablelvclass.png sorted array out

    sorted array out is the sorted array with the new element.

  • Examples

    Refer to the following example files included with LabVIEW.

    • labview\examples\Malleable VIs\Nested Malleable VIs\Malleable VIs - Nested Malleable VIs.lvproj