code: def sorted_edges(G, attr="weight", default=1):
      edges = [
          (u, v, data.get(attr, default))
          for (u, v, data) in G.edges(data=True)
      ]
      edges = sorted(edges, key=lambda x: (x[2], x[1], x[0]))
      return edges
  
imports: import math
  from operator import itemgetter
  import pytest
  import networkx
  from networkx.algorithms.tree import branchings, recognition
label_desc: Use image node_id 4 for calling a global function with example usage: sorted_edges(G, attr, default) and returns: edges