And if the numbers are from different subnets, you could sort like so (assuming addresses are in a 1-dimensional array, here called $IpAddresses): function sort_address($IpAddresses) { $List = array(); foreach ($IpAddresses as $A) { list($x,$y,$z,$t) = explode('.', $A); $List[($x*16777216) + ($y*6553616) + ($z*256) + $t] = $A; } ksort($List, SORT_NUMERIC); return array_values($List); } My first thought was to use the line $List[($x<<24) + ($y<<16) + ($z<<8) + $t] = $A; instead, and gain a little speed advantage by bitshifting instead of multiplying, but then you'd need to force $x, $y, $z and $t to integers first. You might be able to do $List[(((int)$x)<<24) + (((int)$y)<<16) + (((int)$z)<<8) + $t] = $A; or $List[(($x+0)<<24) + (($y+0)<<16) + (($z+0)<<8) + $t] = $A; **************************************************************************** I MADE A BIT OF A CUT'N'PASTE ERROR IN THE LINE ABOVE IN MY PREVIOUS EMAIL! **************************************************************************** instead, though. If you wanted 'em in REVERSE order, use krsort() instead of ksort(). Usual 'untested code' warnings apply. - steve -- +------------------------ Open source questions? ------------------------+ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +----------- http://pgfsun.ucdavis.edu/open-source-tools.html -----------+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]