There is an input array of the form:
var array = [ '<li><input type="radio" name="cityRadio" value="123|Санкт-Петербург">Санкт-Петербург</li>', '<li><input type="radio" name="cityRadio" value="456|Москва">Москва</li>', '<li><input type="radio" name="cityRadio" value="789|Киев">Киев</li>' ]; It is necessary to sort it by city names, so that UL> LI comes first with the city of Kiev, then Moscow, then Peter. I tried this:
array.sort(function (a, b) { return a.match(/(.*)<\/li>/) - b.match(/(.*)<\/li>/); }); but not sorted, not strong in regulars