Javascript: how to sort elements of a class
<p>I have a blog which produces a list like this on a php/html page</p>

<pre><code>&lt;div id="unique-id-4" class="blog-entry"&gt;Bert blah blah&lt;/div&gt;
&lt;div id="unique-id-2" class="blog-entry"&gt;Andy blah blah&lt;/div&gt;
&lt;div id="unique-id-3" class="blog-entry"&gt;Chas blah blah&lt;/div&gt;
&lt;div id="unique-id-1" class="blog-entry"&gt;Dave blah blah&lt;/div&gt;
</code></pre>

<p>I want to reorder the divs on the page using javascript.</p>

<p><strong>Firstly</strong>, to see how it works, an <strong>alphabetical sort</strong>. (That may be enough for this question).
But <strong>secondly</strong> (what I really want to do) <strong>sort them by "age"</strong>. I have an array of each person's name and age which I can reference. Is this even possible?</p>

<p>I found this when looking for finding by class</p>

<p><code>var content = document.getElementsByClassName('blog-entry')</code></p>

<p>The sorted output could be on the same page, or on a different page - it doesn't matter. thanks for any help. I know very little about javascript.</p>

<p>I'd like to sort in the order 
1) Andy, Bert, Chas, Dave (i.e. "alphabetically) producing:</p>

<pre><code>&lt;div id="unique-id-2" class="blog-entry"&gt;Andy blah blah&lt;/div&gt;
&lt;div id="unique-id-4" class="blog-entry"&gt;Bert blah blah&lt;/div&gt;
&lt;div id="unique-id-3" class="blog-entry"&gt;Chas blah blah&lt;/div&gt;
&lt;div id="unique-id-1" class="blog-entry"&gt;Dave blah blah&lt;/div&gt;
</code></pre>

<p>and ideally</p>

<p>2) By their ages, where in a separate array: Andy = 42, Bert =18, Chas = 73, Dave = 56; producing</p>

<pre><code>&lt;div id="unique-id-4" class="blog-entry"&gt;Bert blah blah&lt;/div&gt;
&lt;div id="unique-id-2" class="blog-entry"&gt;Andy blah blah&lt;/div&gt;
&lt;div id="unique-id-1" class="blog-entry"&gt;Dave blah blah&lt;/div&gt;
&lt;div id="unique-id-3" class="blog-entry"&gt;Chas blah blah&lt;/div&gt;
</code></pre>
