G = nx.Graph(edgelist)
for a, b, data in sorted(G.edges(data=True), key=lambda a_b_data: a_b_data[2][
    'weight']):
    print('{a} {b} {w}'.format(a=a, b=b, w=data['weight']))
Сортировка объекта networkx graph Python