code: def cmplx_sort(p):
      """Sort roots based on magnitude.
  
      Parameters
      ----------
      p : array_like
          The roots to sort, as a 1-D array.
  
      Returns
      -------
      p_sorted : ndarray
          Sorted roots.
      indx : ndarray
          Array of indices needed to sort the input `p`.
  
      Examples
      --------
      >>> from scipy import signal
      >>> vals = [1, 4, 1+1.j, 3]
      >>> p_sorted, indx = signal.cmplx_sort(vals)
      >>> p_sorted
      array([1.+0.j, 1.+1.j, 3.+0.j, 4.+0.j])
      >>> indx
      array([0, 2, 3, 1])
  
      """
      p = asarray(p)
      if iscomplexobj(p):
          indx = argsort(abs(p))
      else:
          indx = argsort(p)
      return take(p, indx, 0), indx
  
imports: from __future__ import division, print_function, absolute_import
  import operator
  import threading
  import sys
  import timeit
  from scipy.spatial import cKDTree
  from .None import sigtools, dlti
  from ._upfirdn import upfirdn, _output_len
  from scipy._lib.six import callable
  from scipy._lib._version import NumpyVersion
  from scipy import fftpack, linalg
  from scipy.fftpack.helper import _init_nd_shape_and_axes_sorted
  from numpy import allclose, angle, arange, argsort, array, asarray, atleast_1d, atleast_2d, cast, dot, exp, expand_dims, iscomplexobj, mean, ndarray, newaxis, ones, pi, poly, polyadd, polyder, polydiv, polymul, polysub, polyval, product, r_, ravel, real_if_close, reshape, roots, sort, take, transpose, unique, where, zeros, zeros_like
  import numpy
  import math
  from scipy.special import factorial
  from .windows import get_window
  from ._arraytools import axis_slice, axis_reverse, odd_ext, even_ext, const_ext
  from .filter_design import cheby1, _validate_sos
  from .fir_filter_design import firwin
label_desc: Use image node_id 26 for calling a global function with example usage: cmplx_sort(p) and returns: take,  indx