all of lines 160-168 (i.e. up to the "open(map_type.in_file" line) involve implementation details of Mapping, so this code can with benefit be moved to a method of the Mapping class.
In that case, the class variables referred to here (container, closure, to_sort) then have only internal usage, so make these private (remove from public API)