У меня есть этот код:
$(document).ready(function() {
ofertas_sort = function(sort_key) {
// array of offer divs
var ofertas = $('.infoferta');
// the div classname corresponding to the key by which
// we are sorting
var sort_key_sel = 'div.' + sort_key;
// in large lists it'd be more efficient to calculate
// this data pre-sort, but for this instance it's fine
ofertas.sort(function(a, b) {
return parseInt($(sort_key_sel, a).attr('data-value')) -
parseInt($(sort_key_sel, b).attr('data-value'));
});
// re-fill the container with the newly-sorted divs
$('#ofertas_container').empty().append(ofertas);
};
$('a').click(function() {
ofertas_sort($(this).attr('data-key'));
});
});
Мне нужно сделать наоборот ... но когда я ставлю такие строки:
ofertas.reverse(function(i, e) {
alert(i);
alert(e);
});
, это показывает это сообщение
Uncaught TypeError: Object [object Object] has no method 'reverse'