def order_plan_queryset(plans, field, asc=False):
    """
    Annotate the TestPlan queryset by calling order_by on it.
    """
    orderable_fields = ('plan_id', 'name', 'author__username',
        'owner__username', 'create_date', 'product__name', 'type',
        'num_cases', 'num_runs', 'num_children')
    if field in orderable_fields:
        order_by = field
        if not asc:
            order_by = '-%s' % order_by
        plans = plans.order_by(order_by)
    return plans
