sort mappings by index and move output to files