I would like to sort a div by DESCENDING order based on their image name.
Change From this:
<div id="sort-this-div">
<p><img src="image/1.jpg"/></p>
<p><img src="image/3.jpg"/></p>
<p><img src="image/4.jpg"/></p>
<p><img src="image/2.jpg"/></p>
</div>
To This
<div id="sort-this-div">
<p><img src="image/4.jpg"/></p>
<p><img src="image/3.jpg"/></p>
<p><img src="image/2.jpg"/></p>
<p><img src="image/1.jpg"/></p>
</div>
Here is a way using pure JavaScript. Check it out here.
What this does, it copies all of the src paths for your images into the
sortedvariable, sorts them, and then updates all of the image’s src paths with the new sorted order.UPDATE
Added the custom sort function to address the problem brought up by @EugeneXa