Sort by calculated property

i have IActor interface and types like User and MachineUser
I can query IActor and get both Users and MachineUsers in one request

Can’t sort result by calculated actor name
const name = user.firstName || machineUser.machineUsername

Should i use lambda to generate custom formatted name?

I think it is not efficient to sort during request time if there is no corresponding index.
Can we declare custom index for interface that uses calculated values from related types ?