I want to read all the addresses(IPv4 and IPv6) using getaddrinfo(). My question is whether getaddrinfo() returns IPv6 address followed by IPv4 in the list. Assuming that I'm passing AF_UNSPEC to getaddrinfo() and using dual stack.
As already commented by Celada, RFC 3484 gives a suggested ordering for the returned results.
Specifically for GNU libc, the order can be controlled by /etc/gai.conf
and customised as local policy.