def sort_nodes_by_priority(g):
    """
    Sort node ids in ascending order of priority.
    :param g: a game graph.
    :return: the node ids sorted in ascending order of priority.
    """

    # x is a key of the dictionary a value (1, 4) means player 1, priority 4
    # we return the node id, sorted by priority incrementally
    return sorted(g.nodes.iterkeys(), key=lambda x: g.nodes[x][1])