Try this formula then sort on it.
It will display the IP, no matter the number in the octet as a string with the format of XXX.XXX.XXX.XXX with each number in each section displaying as three digits. For example, 10.57.0.21 displays as 010.057.000.021
stringvar ip:= "10.57.0.21"; //replace with your field
stringvar oct1;
stringvar oct2;
stringvar oct3;
stringvar oct4;
numbervar o1;
numbervar o2;
numbervar o3;
oct1:= left(ip,instr(ip,"."

-1);
o1:=len(oct1)+2;
oct2:= mid(ip,o1,instr(o1,ip,"."

-o1);
o2:=len(oct2)+len(oct1)+3;
oct3:= mid(ip,o2,instr(o2,ip,"."

-o2) ;
o3:=len(oct3)+len(oct2)+len(oct1)+4;
oct4:= right(ip,len(ip)-instrrev(ip,"."

);
totext(val(oct1),"000"

&"." & totext(val(oct2),"000"

&"." & totext(val(oct3),"000"

&"." & totext(val(oct4),"000"
Mike