PINE LIBRARY

InsertionSort

Library "InsertionSort"
Library of sorting algorithm for binary insertion sort and related methods

method binary_insertion_sort(sortedArray, item, order)
  binary insertion sort - inserts item into sorted array while maintaining sort order
  Namespace types: array<float>
  Parameters:
    sortedArray (array<float>): array<float|int> which is assumed to be sorted in the requested order
    item (float): float|int item which needs to be inserted into sorted array
    order (series ORDER): Sort order - positive number means ascending order whereas negative number represents descending order
  Returns: int index at which the item is inserted into sorted array

method binary_insertion_sort(sortedArray, item, order)
  Namespace types: array<int>
  Parameters:
    sortedArray (array<int>)
    item (int)
    order (series ORDER)
arrayshewhomustnotbenamed

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.

Disclaimer