Accepted answer

actually, it fails for age too:

expression of type 'system.int32' cannot be used for return type 'system.object'

the immediate issue is that you need a conversion (a box in this case) from a value-type to an object:

var mysortexpression = expression.lambda<func<objecttoorder, object>>(
    expression.convert(, field),
    ), param);

however, using object here could in-and-of-itself be problematic. i suggest looking at dynamic linq orderby on ienumerable<t>

Related Query

More Query from same tag