Python script to sort IPs from STDIN