Echo a hierarchical list of post data from custom fields

A little example, based on get_posts and get_post_meta.

$locations = get_posts(
    array('post_type' => 'locations',
        'posts_per_page' => -1,
        'post_status' => 'publish'
    );
echo '<ul>';
foreach ($locations as $location) {
  $location_city = get_post_meta($location->ID, 'city', true);
  $location_state = get_post_meta($location->ID, 'state', true);
  $location_address = get_post_meta($location->ID, 'address', true);

  echo '<li>' . $location_city;
  echo '<li>' . $location_state . '</li>';
  echo '<li>' . $location_address . '</li>';
  echo '</li>';
}
echo '</ul>';

You’ll need to adapt $args array in the get_posts to order by special value. With this way you loop through posts and retrieve their custom fields with get_post_meta.

Edit:
You can add a meta_query array in the arguments for the query, to get or order.
Custom field in WP_Query

Hope it helps.