I'm looking for some sample code that will sort the list items in an HTML list by alphabetical order. Can anyone help?
Here is a sample list for people to work with:
<ul class="alphaList">
<li>apples</li>
<li>cats</li>
<li>bears</li>
</ul>
Try this:
For future googlers, I've found this plugin very useful. It has option to define character order for non-latin languages.
Older versions (jQuery dependent)
For English only characters, no option is needed to define
Current version (jQuery independent) (29 March 2016)
Current version of tinysort is now independent from jQuery. Pure JavaScript. I updated jsfiddle for new version usage.
Demo http://jsfiddle.net/ergec/EkScy/
Website http://tinysort.sjeiti.com/