fixed $sort dynamic type casting