As I described in the 2 outputs, the C# one returns addresses in the correct order (increasing interface metric) while the perl one returns it in the reverse order (decreasing metric). It has nothing to do with the byte order of the individual ip address.