code: def sort_complex2(c, a):
      """
      - c and a are partially sorted (either the last one is bad, or the first one)
      - pos : 0 (first one out of order)
             -1 (last one out of order)
      """
      # find where new key is relative to the rest
      if a[0] < a[1]:
          ax, cx = a[0], c[0]
          ind = myinsert(a[1:], ax)
          a[0:ind], a[ind] = a[1 : 1 + ind], ax
          c[0:ind], c[ind] = c[1 : 1 + ind], cx
      elif a[-1] > a[-2]:
          ax, cx = a[-1], c[-1]
          ind = myinsert(a[0:-1], ax)
          a[ind + 1 :], a[ind] = a[ind:-1], ax
          c[ind + 1 :], c[ind] = c[ind:-1], cx
      return
  
file_path: mystic/mystic/scemtools.py
imports: import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: sort_complex2(c, a) without return types