def sort_orbitals(element_pdos):
    """Sort the orbitals of an element's projected density of states.

    Sorts the orbitals based on a standard format. E.g. s < p < d.
    Will also sort lm decomposed orbitals. This is useful for plotting/saving.

    Args:
        element_pdos (dict): An element's pdos. Should be formatted as a
            :obj:`dict` of ``{orbital: dos}``. Where dos is a
            :obj:`~pymatgen.electronic_structure.dos.Dos` object. For example::

                {'s': dos, 'px': dos}

    Returns:
        list: The sorted orbitals.
    """
    sorted_orbitals = [
        "s",
        "p",
        "py",
        "pz",
        "px",
        "d",
        "dxy",
        "dyz",
        "dz2",
        "dxz",
        "dx2",
        "f",
        "f_3",
        "f_2",
        "f_1",
        "f0",
        "f1",
        "f2",
        "f3",
    ]
    unsorted_keys = element_pdos.keys()

    sorted_keys = []
    for key in sorted_orbitals:
        if key in unsorted_keys:
            sorted_keys.append(key)

    return sorted_keys