Asuming that you have a variable called $posts
that contains all the posts (or easier: Post IDs) from some query.
You can then work with $result
and process everything you need. Calling post data is easy, as the key would be the post ID.
// For other arguments look into @link http://codex.wordpress.org/Class_Reference/WP_Query
$posts = new WP_Query(
'post_type' => 'portfolio'
,'post_status' => 'publish'
);
foreach ( $posts as $post )
{
$result[ $post->ID ]['post_data'] = $post->ID;
$result[ $post->ID ]['meta_data'] = get_post_custom( $post->ID );
}
foreach( $result as $id => $data )
{
// Do whatever you need to do with your meta data in here.
print 'The title is: '.$post->post_title;
// See your post data:
print_r( $data['post_data'] );
// See your meta data:
print_r( $data['meta_data'] );
}