def order_keys(keys, orders):
    """Get ordered keys.

    :param keys: keys to be sorted.
    :type keys: list of str
    :param orders: the order of the keys. '.' is all other keys not in order.
    :type orders: list of str.

    :returns: keys as list sorted by orders.

    :raises: TypeError if keys or orders is not list.
    """

    if not isinstance(keys, list):
        raise TypeError('keys %s type should be list' % keys)

    if not isinstance(orders, list):
        raise TypeError('orders ^s type should be list' % orders)

    found_dot = False
    pres = []
    posts = []
    for order in orders:
        if order == '.':
            found_dot = True
        else:
            if found_dot:
                posts.append(order)
            else:
                pres.append(order)

    return ([pre for pre in pres if pre in keys] +
            [key for key in keys if key not in orders] +
            [post for post in posts if post in keys])