In Moodle table I want to sort column on name of cohort, but it's keeping sorting on cohortid. In end of url stays &tsort=cohortid.
My code in the function is beneath, what would be the necessary change?
global $DB;
$rs = array();
$records = $DB->get_records_sql("SELECT c.id, c.name FROM {cohort} c
LEFT JOIN {block_name_of_block} b ON b.cohortid = c.id
WHERE b.cohortid = ?
ORDER BY c.name ASC
", array($values->cohortid, $sort='c.name'));
foreach ($records as $record) {
$rs[] = $record->name;
}
return .. (=url)