def extract_group_key_order(name):
    """Extract group key and order from name.

    Parameters
    ----------
    name : str
        name of the file.

    Returns
    -------
    group_key : tuple
        The group the build should belong to

    order : tuple
        The order used to sort the builds.
        The higher the latest
    """
    assert name.endswith(".whl")
    name = name[:-4]
    arr = name.split("-")

    pkg_name = arr[0]
    group_key = [arr[0]] + arr[2:]

    ver = arr[1]
    plus_pos = ver.find("+")
    if plus_pos != -1:
        ver = ver[:plus_pos]

    dev_pos = ver.find(".dev")
    if dev_pos != -1:
        # all nightly share the same group
        group_key.append("nightly")
        # dev number as the order.
        pub_ver = [int(x) for x in ver[:dev_pos].split(".")]
        order = pub_ver + [int(ver[dev_pos + 4 :])]
    else:
        # stable version has its own group
        group_key.append(ver)
        order = [0]

    return tuple(group_key), tuple(order)