$('#btnRearrange').bind("click", function() {
var contents = {}, text;
$("#test td").each(function() {
text = $(this).text();
if( !( text in contents ) ) {
contents[text] = true;
}
else {
$( this.parentNode ).remove();
}
});
});
jsfiddle: http://jsfiddle.net/jKs4k/