Claudio is right, in your case you don't need a where clause but you do have to pass the variables into the function. The way it's written now the literal strings ":orderby" and ":tabledef" are being passed in and of course the ad_order_by_from_sort_spec emits an empty string since it
does not have a properly structured tabledef list to work with.