Since I had to deal a bit with lists of IP addresses recently I did some research on how to efficiently sort IP addresses in dotted-decimal notation, e.g.
188.8.131.52. You can find how to do it easily when searching the web. Anyway, I found a nice discussion thread started by Rick Moen in " Puzzle: How do you sort IP address lists?" which features a number of solutions.
Here is one of them which is rather efficient and can be done with sort from GNU coreutils (my version as of now is v5.97):
sort -n -t. -k 1,1 -k 2,2 -k 3,3 -k 4,4
-u if you want unique output.