Skip to content

Instantly share code, notes, and snippets.

@fredacx
Created April 26, 2013 20:38
Show Gist options
  • Save fredacx/5470287 to your computer and use it in GitHub Desktop.
Save fredacx/5470287 to your computer and use it in GitHub Desktop.
// Ordenação
$('#maisvotados').on('click', function(){
array = new Array();
var i = 1;
$('.item-votacao').each(function(){
i+=1;
array[($(this).data('votos')+1) +''+ i] = $(this);
});
array.sort(function(a,b) {
return a > b;
});
console.log(array);
$('.item-geral ul').hide();
$('.item-geral ul').empty();
for(var i in array) {
console.log(i);
$('.item-geral ul').append(array[i]);
$('.item-geral ul').fadeIn('slow');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment