Do not attempt to sort the files in awk. Use awk to format the output, and then use sort to sort it, (and perhaps sed to strip away any stuff that was used to help you sort).