I\'m trying to sort an li elements and get an unexpacted result I need to sort it three times to get it correctly,
li
where have I mistaken? javascript
var sort_by_name = function(a, b) { return $(a).text().toLowerCase().localeCompare($(b).text().toLowerCase()); }
You can use localeCompare instead to make things more elegant and workable.
See jsfiddle http://jsfiddle.net/Qww87/11/