After trying the tutorials I would like to modify the bookmarker tutorial to include the functionality of sorting data before displaying it in the view. In the tutorial you create a link to sort while clicking but I would like to output the data sorted by one of the columns directly. You can sort data in a number of ways. One way is to sort the data in the database every time you add a new entity, another is to leave the database alone and sort just before outputting to the view. When I try to sort in the view I just cannot get it to work.
<?php foreach ($users as $user): ?>
<tr>
<td><?= h($user->username) ?></td>
<td><?= h($user->region) ?></td>
</tr>
<?php endforeach; ?>
let's say we want to sort by region. The data in $user is accessible and displayed as an output. My question is: how do you sort the date in $user by region? i've tried to use the ksort but no success so far.
$users=Set::sort($user,'region','DESC');
getting the error:
Error: Class 'Set' not found File C:\wamp\www\laravel\src\Template\Users\index.ctp Line: 14
Thanks for your help.
C:\wamp\www\laravel
<- are you sure you're using CakePHP..? – AD7six