title: How to Sort Images by Dimension
body: <p>I try to find all images in a web page, add them in an array, check their dimensions and sort the array accordingly.</p>
  
  <pre><code>var images = document.getElementsByTagName("img");
  var image_dimensions=[];
  for(var i=0;i&lt;images.length;i++){
      image_dimensions.push(images[i].width+"x"+images[i].height);
  }
  
  //var image_dimensions = ["45x67", "68x45", "12x23", "124x90"];
  </code></pre>
  
  <p>I want to sort the images according to their dimensions and update the <code>images</code> array. I tried to push dimensions into <code>image_dimensions</code> and sort it but later I could not figure out how can I relate the dimensions to the actual img nodes.</p>
  
  <p>How can I sort the images in a web page by dimension?</p>