code: def longest_track_bundle(bundle, sort=False):
      """Return longest track or length sorted track indices in `bundle`
  
      If `sort` == True, return the indices of the sorted tracks in the
      bundle, otherwise return the longest track.
  
      Parameters
      ----------
      bundle : sequence
         of tracks as arrays, shape (N1,3) ... (Nm,3)
      sort : bool, optional
         If False (default) return longest track.  If True, return length
         sorted indices for tracks in bundle
  
      Returns
      -------
      longest_or_indices : array
         longest track - shape (N,3) -  (if `sort` is False), or indices
         of length sorted tracks (if `sort` is True)
  
      Examples
      --------
      >>> from dipy.tracking.metrics import longest_track_bundle
      >>> import numpy as np
      >>> bundle = [np.array([[0,0,0],[2,2,2]]),np.array([[0,0,0],[4,4,4]])]
      >>> longest_track_bundle(bundle)
      array([[0, 0, 0],
             [4, 4, 4]])
      >>> longest_track_bundle(bundle, True) #doctest: +ELLIPSIS
      array([0, 1]...)
  
      """
      alllengths = [length(t) for t in bundle]
      alllengths = np.array(alllengths)
      if sort:
          ilongest = alllengths.argsort()
          return ilongest
      else:
          ilongest = alllengths.argmax()
          return bundle[ilongest]
  
imports: from dipy.utils.deprecator import deprecate_with_version
  from dipy.tracking.streamline import set_number_of_points
  import numpy
  from scipy.interpolate import splprep, splev
label_desc: Use image node_id 12 for calling a global function with example usage: longest_track_bundle(bundle, sort) and returns: ilongest, bundle