<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def put(self, block_id, priority, pb_type='offline'):
 """Add a Processing Block to the queue. When a new entry it added, the queue is (re-)sorted by priority followed by insertion order (older blocks with equal priority are first). Args: block_id (str):
 Processing Block Identifier priority (int):
 Processing Block scheduling priority (higher values = higher priority) pb_type (str):
 Processing Block type (offline, realtime) """

        if pb_type not in ('offline', 'realtime'):
            raise ValueError('Invalid PB type.')

        with self._mutex:
            added_time = datetime.datetime.utcnow().isoformat()
            entry = (priority, sys.maxsize-self._index, block_id, pb_type,
                     added_time)
            self._index += 1
            if self._block_map.get(block_id) is not None:
                raise KeyError('ERROR: Block id "{}" already exists in '
                               'PC PB queue!'.
                               format(block_id))
            self._block_map[block_id] = entry
            LOG.debug("Adding PB %s to queue", block_id)
            self._queue.append(entry)
            self._queue.sort()  # Sort by priority followed by insertion order.
            self._queue.reverse()