Sort the elements and test the connection_type