Format attributes to an array before joining with sort attributes
Fix syntax error