Unix command to sort a file based on a certain column numerically

Please see the attached file for the complete problem.
Please help me with this programming question:
Create a single command string that will modify the file called myfile and change all occurrences of the ! to a :. The command string must also sort the file numerically on the GID field and then save the output to a file called newfile.
Replace the ## in the command string below with the correct characters to make the above described work.
sed 's/!/:/g' myfile | sort -### -t: > ~/newfile

Attachments

Solution Preview

(Please see the attached files for the complete solution).
In order to sort a file according to a certain field, you need to specify a Field Separator or delimiter using -t.
Since the GID values are numbers, we need to specify another sorting option "n".
Finally, we want to sort the file according to the third field (the GID field), therefore, we need to use the -k option which specifies the range of fields to ...

Solution Summary

The solution explains how to use different options with the important Unix sort command to accomplish numerical sorting of a certain field in a field separated file.