From the docs:
Syntax
condition ? expr1 : expr2
Parameters
condition (or conditions)
An expression that evaluates to true or false.
expr1, expr2
Expressions with values of any type.
You should pay attention to the Expressions with values of any type
., the return xxx
is not an expression.
From wikipedia:
An expression is a syntactic construct, it must be well-formed: the allowed operators must have the correct number of inputs in the correct places, the characters that make up these inputs must be valid, have a clear order of operations, etc. Strings of symbols that violate the rules of syntax are not well-formed and are not valid mathematical expressions.
So, in your case you can use:
return sort.attr('selected') ? true : false