def cmp_sort(a, b):
    """ Sorting key. If gantry angle is equal, then sort by couch angle.
    """
    if a['gantry'] == b['gantry']:
        return a['couch'] - b['couch']
    return a['gantry'] - b['gantry']
