This is the query which is already ordered by points:
$data['users'] = $this->db->select( array( 'users_avatar', 'users_teams_id', 'users_id', 'users_name', 'users_win', 'users_lose', 'users_points', 'daily_points' ) )->order_by( 'daily_points', 'desc' )->limit( 26 )->get( 'users' )->result();
So, it working correctly in the displaying top users by points but however if top users have same points they are appearing really weird. I want to make sure at least top 3 users if same points to display them descending on the name but it seems it must be done in the foreach loop which i am not sure how to do it correctly. Below is the displaying code: (top 3 users have medal appearing based on 1st,2nd and 3rd thats why its like that with divs for th)
<div class="dailyleft" id="teams_inner">
<div id="teams_for_scroll">
<?
$i = 1;
sort($i);
foreach($users as $user)
{
echo '
<div class="row">'.(
(($i == '1')?'<div class="num_1"></div>':'').
(($i == '2')?'<div class="num_2"></div>':'').
(($i == '3')?'<div class="num_3"></div>':'').
(($i > '3')?'<div class="num">'.$i.'</div>':'')
).'<img src="'.base_url().'public/uploads/t_'.$user->users_avatar.'" />
<div class="title" style="width:400px;">'.($user->users_teams_id?'<a class="team_link" href="'.site_url('teams/view/'.$user->users_teams_id).'">['.$user_teams[$user->users_teams_id].']</a>':'').' '.htmlspecialchars($user->users_name, ENT_QUOTES).'</div>
<div class="points" style="width:150px;"><span>Daily Points</span><font color="orange">'.number_format($user->daily_points, 0, ' ', ' ').'</font></div>
<div class="points" style="width:230px;"><span>All Time Win/ Lose</span>'.number_format($user->users_win, 0, ' ', ' ').' / '.number_format($user->users_lose, 0, ' ', ' ').'</div>
</div>
';
$i++;
}
?>
</div>
</div>