replaced fetchrow_array with loop that fetches hash directly.  also added sort to sort based on network address.