You cannot assign a return statement to a variable. If you want active to be assigned the value true or false, just delete the returns:
var active = sort.attr('selected') ? true : false;
or maybe better:
var active = sort.prop('selected');
since .prop always returns true or false, regardless of the initial tag attribute.