import networkx as nx
edgelist = [(1, 3, {'weight': 5250}), (1, 4, {'weight': 74}), (1, 5, {
    'weight': 3659})]
G = nx.Graph(edgelist)
for a, b, data in sorted(G.edges(data=True), key=lambda a_b_data: a_b_data[2][
    'weight']):
    pass
Sorting a networkx graph object Python