title: Ruby, Nokogiri: sort nodeset by attribute value
body: <p>I would like to sort a Nokigiri nodeset by the title value. Tried the following code, but sorting is not working :/ Any suggestions?</p>
  
  <pre><code>doc.xpath("//item").sort{|x,y| x.xpath('foo:attr[@name="title"]/@value').text &lt;=&gt; y.xpath('foot:attr[@name="title"]/@value').text }
  </code></pre>
  
  <p>XML example:</p>
  
  <pre><code>&lt;item&gt;
    &lt;foo:attr name="title" value="a"/&gt;
  &lt;/item&gt;
  &lt;item&gt;
    &lt;foot:attr name="title" value="c"/&gt;
  &lt;/item&gt;
  &lt;item&gt;
    &lt;foor:attr name="title" value="b"/&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>Output I am looking for: (nodeset)</p>
  
  <pre><code>&lt;item&gt;
    &lt;foo:attr name="title" value="a"/&gt;
  &lt;/item&gt;
  &lt;item&gt;
    &lt;foot:attr name="title" value="b"/&gt;
  &lt;/item&gt;
  &lt;item&gt;
    &lt;foor:attr name="title" value="c"/&gt;
  &lt;/item&gt;
  </code></pre>