def generate_order_by_clause(params):
    """Generates order_by clause strings from the given list.

    :param list params: A list of column names to sort the result to::

        params = [
            'id', 'name', 'full_path', 'parent_id',
            'resource', 'status', 'project_id',
            'task_type', 'entity_type', 'percent_complete'
        ]

      will result a search string like::

        order by
            tasks.id, tasks.name, tasks.full_path,
            tasks.parent_id, , resource_info.info,
            "Statuses".code, "Tasks".project_id, task_types.name,
            tasks.entity_type
    """

    order_by_string = ''
    order_by_string_buffer = []

    column_dict = {
        'id': 'id',
        'parent_id': "parent_id",
        'name': "name",
        'path': "full_path",
        'full_path': "full_path",
        'entity_type': "entity_type",
        'task_type': "task_types.name",
        'project_id': 'project_id',
        'date_created': 'date_created',
        'date_updated': 'date_updated',
        'has_children': 'has_children',
        'link': 'link',
        'priority': 'priority',
        'depends_to': 'dep_info',
        'resource': "resource_info.resource_id",
        'responsible': 'responsible_id',
        'watcher': 'watcher_id',
        'bid_timing': 'bid_timing',
        'bid_unit': 'bid_unit',
        'schedule_timing': 'schedule_timing',
        'schedule_unit': 'schedule_unit',
        'schedule_model': 'schedule_model',
        'schedule_seconds': 'schedule_seconds',
        'total_logged_seconds': 'total_logged_seconds',
        'percent_complete': 'percent_complete',
        'start': 'start',
        'end': '"end"',
        'status': '"Statuses".code',
    }
    for column_name in params:
        order_by_string_buffer.append(column_dict[column_name])

    if len(order_by_string_buffer):
        # need to indent the first element by hand
        order_by_string = 'order by %s' % ', '.join(order_by_string_buffer)

    return order_by_string