title: Sorting a networkx graph object Python
body: <p>I want to sort a graph object that I have read through networkx library in Python, in the increasing order of edgeweight. It seems that the <code>sort</code> command of python won't apply to graph objects. I am sure there is a easy way to sort this object, but I am not sure how. Any help will be appreciated.</p>
  
  <p>For example, my first three edges are</p>
  
  <pre><code>1 3 5250
  1 4 74
  1 5 3659
  </code></pre>
  
  <p>After sorting I would hope that their order is changed to</p>
  
  <pre><code>1 4 74
  1 5 3659
  1 3 5250
  </code></pre>
  
  <p>Here is my code so far</p>
  
  <pre><code>import networkx as nx
  g=nx.read_weighted_edgelist(fname,nodetype=int)
  </code></pre>
  
  <p>I am trying to sort the object <code>g</code>.</p>