def sort_proteome_frame(frame):
    """Sort a proteome frame by preference and frag.max and renumber."""
    frame = frame.copy()
    if frame.index.name == "path":
        frame["path"] = frame.index
    frame.sort_values(
        by=["preference", "frag.max"], ascending=[True, False], inplace=True
    )
    frame["order"] = range(len(frame))
    frame.set_index("order", inplace=True)
    return frame