def sort_contests(a, b):
    if a["has_started"] and b["has_started"]:
        return a["end"] < b["end"]
    elif a["has_started"] and b["has_started"] == False:
        return False
    elif a["has_started"] == False and b["has_started"]:
        return True
    else:
        return a["start"] < b["start"]

# ----------------------------------------------------------------------------
dataset/ETHPy150Open stopstalk/stopstalk-deployment/controllers/default.py/sort_contests/original