Sort table row from data attribute

Sort table row from data attribute

Hi,

I have the following code and despite all my attempts it doesn't sort.  I've console.log before and after and it's the same.  When I debug the comparison it returns the right value.  I'm wondering what I'm doing wrong

  1. var Elements = $('#tablecontent tr');
  2. $(Elements).sort(function (a, b) {
        var contentA = $(a).data(SelectedSORT == 'ROOM' ? 'appartment' : 'fullname');
        var contentB = $(b).data(SelectedSORT == 'ROOM' ? 'appartment' : 'fullname');
  3.     return (contentA < contentB ? 1 : 0);
    });
  4. $('#tablecontent').empty
    $('#tablecontent').append(Elements);