Comparing files enen when they are not in order

Hi,

I have two master files which contain the information for many jobs like this

Job no:1 a b c d
Job no:1 d e g h

Job no:2 t j s h
Job no:2 t j s h

I have written a script to pick up all the information for Job no:1 from file1 and put that to a temporary file and do the same from file2 and put it to a temporary file. Then i will compare this two temporary files using diff. If they dont match print the information for that Job from both the master files in to one output file.After the comparison is done for one job,i will read the information for the next job and compare. Here the problem is if the order of the information for Job number changes like this

In file1 i have

Job no:1 a b c d
Job no:1 d e g h

In file 2 i have

Job no:1 d e g h
Job no:1 a b c d
Here diff would fail even though there is no mismatch except the order has changed which is not an issue. Is there any other way to read the information for a particular job from file one and then print out that to a file. Then do the same for the information from file2.Then compare.If they are same leave it else print information from both the master files to the output file.

Sort the files before doing a diff on them so if file1 is sorted but not file2 then...

sort -n file2 | diff file1 -

Oh. Thanks. Thats really a good idea.