in reply to file comparison

If output order doesn't matter, then just sort the two files before diffing. If it kind of matters, i.e. only local reordering is allowed, then you'll need to be more specific, but you can probably sort consecutive groups of lines and compare them:
for i = 1 .. n - k: if (sort(expected[i..i+k]) != sort(actual[i..i+k])): print "Mismatch around line ", i