write_network_interfaces: improved sorting