def swap_axes(ranges):
    """Swaps the ":math:`i`" and ":math:`j`" axes of a reduction's optional **ranges** parameter.
    
    This function returns **None** if **ranges** is **None**,
    and swaps the :math:`i` and :math:`j` arrays of indices otherwise."""
    if ranges is None:
        return None
    else:
        return *ranges[3:6], *ranges[0:3]
