You achieve this by modifying your code as following and using get_results function instead of get_col function.
<?php
function get_meta_values( $key = '', $type="post", $status="publish" ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_results( $wpdb->prepare( "
SELECT pm.meta_value, p.ID FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status="%s"
AND p.post_type="%s"
ORDER BY pm.meta_value ASC
", $key, $status, $type ) );
return $r;
}
?>
<?php $my_list_items = get_meta_values( 'realname' ); ?>
<h3>PEOPLE ALREADY REGISTERED - ALPHABETICAL ORDER :</h3>
<ol>
<?php
if ( $my_list_items ) {
foreach( $my_list_items as $my_list_item ) { ?>
<li><a href="https://wordpress.stackexchange.com/questions/110589/<?php echo get_permalink( $my_list_item->ID ); ?>"><?php echo $my_list_item->meta_value; ?></a></li>
<?php }
}?>
</ol>