def fieldSorter(fieldname, forcedOrder=None):
    """Sort a field

    A generic sorter which allows to define a field for sorting.

    If forcedOrder is not None it will be used as the sort order.
    """
    def handleSort(order):
        if forcedOrder is not None:
            order = forcedOrder
        return {fieldname: {"order": order}}
    return handleSort