tool: Sort patches when generating port hashes

Issue #1082