in reply to Need sorting help

The <=> operator does a numeric comparison. The IP addresses are not numbers, you want cmp. Try replacing all <=> with cmp.

Update: Ah, the benefit of not reading the question before answering it.

What I should have suggested is that you construct a key for each row based on the data in the row. If you, say append the source and target IP addresses (i.e. make "$src:$target" the key) (remembering to reverse the order when dealing with a reply) then it should all work. You may need to also incorporate some other data, for example, the time to ensure uniqueness?