/**
 * Displays a human-readable list of entities
 *
 * @param string $relationship The relationship eg "friends_of"
 * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)
 * @param string $type The type of entity (eg 'object')
 * @param string $subtype The entity subtype
 * @param int $owner_guid The owner (default: all)
 * @param int $limit The number of entities to display on a page
 * @param true|false $fullview Whether or not to display the full view (default: true)
 * @param true|false $viewtypetoggle Whether or not to allow gallery view
 * @param true|false $pagination Whether to display pagination (default: true)
 * @return string The viewable list of entities
 */
function list_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true)
{
    $limit = (int) $limit;
    $offset = (int) get_input('offset');
    $count = get_entities_by_relationship_count($relationship, $inverse_relationship, $type, $subtype, $owner_guid, 0, 0, true);
    $entities = get_entities_by_relationship_count($relationship, $inverse_relationship, $type, $subtype, $owner_guid, $limit, $offset);
    return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
}
<?php

require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php";
$limit = get_input('count', 16);
$mode = get_input('type', 10);
switch ($mode) {
    case "m_latest":
        //$members = get_entities_from_metadata('icontime', '', 'user', '', 0, 10);
        $members = get_entities("user", "", 0, '', $limit, 0);
        break;
    case "m_views":
        $members = get_entities_by_relationship_count('friend', true, '', '', 0, $limit);
        break;
    case "m_com":
        $members = find_active_users(600, $limit, $offset);
        break;
}
if (isset($members)) {
    //display member avatars
    foreach ($members as $member) {
        echo "<div class=\"index_members\">";
        echo elgg_view("profile/icon", array('entity' => $member, 'size' => 'small'));
        echo "</div>";
    }
}
?>
<div class="clearfloat"/>