obspy.imaging.util._component_code_key

_component_code_key(val)[source]

Compare two single character component codes according to sane ZNE/ZRT/LQT order. Any other characters are sorted afterwards alphabetically.

>>> from random import shuffle
>>> from string import ascii_lowercase, ascii_uppercase
>>> lowercase = list(ascii_lowercase)
>>> uppercase = list(ascii_uppercase)
>>> shuffle(lowercase)
>>> shuffle(uppercase)
>>> component_codes = lowercase + uppercase
>>> component_codes = sorted(component_codes,
...                          key=_component_code_key)
>>> print(component_codes)  
['z', 'Z', 'n', 'N', 'e', 'E', 'r', 'R', 'l', 'L', 'q', 'Q', 't', 'T', 'a',
    'A', 'b', 'B', 'c', 'C', 'd', 'D', 'f', 'F', 'g', 'G', 'h', 'H', 'i',
    'I', 'j', 'J', 'k', 'K', 'm', 'M', 'o', 'O', 'p', 'P', 's', 'S', 'u',
    'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y']