def _format_order(order_dict):
    """
    Formats an order dict into an ORDER BY clause.
    """
    if order_dict:
        return "ORDER BY " + " ".join(["{}(?{})".format("ASC" if order_dict[pos][1] else "DESC", order_dict[pos][0]) for pos in sorted(order_dict)])
    return ""