I have a div which contains a number of links.
Each link has a "data-direction" attribute, containing an integer of 1, 2, or 3.
I want to add a click event to a button to sort the links in the div, first by the "data-direction" attribute and then by the link text.
e.g., if I start with the following:
<div id="link_list">
<a href="#" data-direction="2">Allergy</a>
<a href="#" data-direction="1">Walking</a>
<a href="#" data-direction="3">Belltower</a>
<a href="#" data-direction="1">Apple</a>
<a href="#" data-direction="2">Affable</a>
</div>
...my goal is to sort as:
<div id="link_list">
<a href="#" data-direction="1">Apple</a>
<a href="#" data-direction="1">Walking</a>
<a href="#" data-direction="2">Allergy</a>
<a href="#" data-direction="2">Affable</a>
<a href="#" data-direction="3">Belltower</a>
</div>