def sort_schedule_setpoint_items(items):
    """
    This can be used to sort the items of schedule/setpoint.

    The ordering is especially relevant if items overlap, which should not
    exist though. But if it does, the following ensures that in case of
    overlap we start with the first item and switch to the second once the
    time of the second has come. If items have from_timestamp = None, then
    they will be executed at the very beginning, as everything with a specified
    from_timestamp is certainly thought to start later. If multiple items exist
    for which from_timestamp is None we take care that an item that has also
    to_timestamp = None is the last of the ones with from_timestamp = None, as
    we exepct that this item is then ment to be executed.
    """
    def sort_key(item):
        """
        Inspred by:
        https://stackoverflow.com/questions/18411560/python-sort-list-with-none-at-the-end
        """
        return (
            item["from_timestamp"] is not None,
            item["to_timestamp"] is None,
            item["from_timestamp"]
        )
    return sorted(items, key=sort_key)