code: def sorting(ascending=True, outer=False):
      """impose sorting on the given function
  
      The function will use sorting, where:
        - ascending is bool, increasing with index if True and decreasing if False
        - outer is bool, applied to the outputs if True and to the inputs if False
  
      Examples:
        >>> @sorting(outer=True)
        ... def squared(x):
        ...     return [i*i for i in x]
        ...
        >>> squared([5.34, -.121, -4.11, 9.01, 11.3, -16.4])
        [0.014641, 16.892100000000003, 28.5156, 81.1801, 127.69000000000001, 268.96]
        >>>
        >>> @sorting()
        ... def squared(x):
        ...     return [i*i for i in x]
        ...
        >>> squared([5.34, -.121, -4.11, 9.01, 11.3, -16.4])
        [268.96, 16.892100000000003, 0.014641, 28.5156, 81.1801, 127.69000000000001]
      """
  
      def _sort(x, ascending=True):
          if not hasattr(x, "__len__"):
              return x
          if isinstance(x, ndarray):
              xtype = asarray
          else:
              xtype = type(x)
          return xtype(sorted(x, reverse=(not ascending)))
  
      def dec(f):
          def func(x, *args, **kwds):
              if outer:
                  return _sort(f(x, *args, **kwds), ascending=ascending)
              return f(_sort(x, ascending=ascending), *args, **kwds)
  
          func.sorting = _sort
          func.__wrapped__ = f
          func.__doc__ = f.__doc__
          return func
  
      return dec
  
imports: from mystic.math.measures import *
  from mystic.math import almostEqual
  from numpy import sum
  from numpy import asfarray, asarray, choose, zeros, ones, ndarray
  from numpy import shape, broadcast, empty, atleast_1d
  from numpy import round, abs
  from random import randrange, shuffle
  from numpy import array, intersect1d, inf, isnan, where, choose, clip
  from numpy.random import uniform, choice
  from numpy import maximum, minimum
  from numpy import round, abs
  from mystic.tools import synchronized, connected
  from mystic.math.discrete import product_measure
label_desc: Use image node_id 25 for calling a global function with example usage: sorting(ascending, outer) and returns: dec, xtype, func, x, f, _sort