def _infinite_strings(key=None):
    """Returns a function which returns a float: either 'inf' for a
    (base)string, or the float(value) for the argument. Intended for
    sorting numbers before strings. Accepts a 'key' argument as for
    sorting algorithms.
    """
    def _sort_func(value):
        if key is not None:
            value = key(value)
        if isinstance(value, str) or value is None:
            value = float('inf')
        else:
            value = float(value)
        return value

    return _sort_func