sorting/searching in active record by calculated fields

What is the best way to do sorting/searching in active record by
calculated fields.

Regards,
Pankaj