I'd like to sort the result of find according to the name of the input
as follows:
HTML:
<form id="sort" ...>
<input name=...>
<input name=...>
...
</form>
jQuery:
var result = $('#sort').find('input');
var serialized = result.sort(comparer(result)).serialize();
function comparer(index) {
return function(a, b) {
var valA = getCellValue(a, index);
var valB = getCellValue(b, index);
return valA.localeCompare(valB);
};
};
function getCellValue(element, index) {
return element.attr('name');
};
It doesn't work; error message: Uncaught TypeError: undefined is not a function
on the line: return valA.localeCompare(valB);
The above was from this, but I don't quite understand the comparer function.