<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, stream: typing.BinaryIO, be: bool) -> None: """Write the RSTB to the specified stream."""

        stream.write(b'RSTB')
        stream.write(_to_u32(len(self.crc32_map), be))
        stream.write(_to_u32(len(self.name_map), be))

        # The CRC32 hashmap *must* be sorted because the game performs a binary search.
        for crc32, size in sorted(self.crc32_map.items()):
            stream.write(_to_u32(crc32, be))
            stream.write(_to_u32(size, be))

        # The name map does not have to be sorted, but Nintendo seems to do it, so let's sort too.
        for name, size in sorted(self.name_map.items()):
            stream.write(struct.pack('128s', name.encode()))
            stream.write(_to_u32(size, be))