argsort

  • full name: tenpy.tools.misc.argsort

  • parent module: tenpy.tools.misc

  • type: function

tenpy.tools.misc.argsort(a, sort=None, **kwargs)[source]

wrapper around np.argsort to allow sorting ascending/descending and by magnitude.

Parameters:
  • a (array_like) – The array to sort.

  • sort ('m>', 'm<', '>', '<', None) –

    Specify how the arguments should be sorted.

    sort

    order

    'm>', 'LM'

    Largest magnitude first

    'm<', 'SM'

    Smallest magnitude first

    '>', 'LR', 'LA'

    Largest real part first

    '<', 'SR', 'SA'

    Smallest real part first

    'LI'

    Largest imaginary part first

    'SI'

    Smallest imaginary part first

    None

    numpy default: same as ‘<’

  • **kwargs – Further keyword arguments given directly to numpy.argsort().

Returns:

index_array – Same shape as a, such that a[index_array] is sorted in the specified way.

Return type:

ndarray, int