protected function get_keyfield(?int $sortmethod) : string {
        switch ($sortmethod) {
            case self::SORTORDER_CREATED_DESC:
            case self::SORTORDER_CREATED_ASC:
                return 'fp.created';
            case self::SORTORDER_REPLIES_DESC:
            case self::SORTORDER_REPLIES_ASC:
                return 'replycount';
            default:
                global $CFG;
                $alias = $this->get_table_alias();
                $field = "{$alias}.timemodified";
                if (!empty($CFG->forum_enabletimedposts)) {
                    return "CASE WHEN {$field} < {$alias}.timestart THEN {$alias}.timestart ELSE {$field} END";
                }
                return $field;
        }
    }
protected function get_keyfield(?int $sortmethod) : string {
        switch ($sortmethod) {
            case self::SORTORDER_CREATED_DESC:
            case self::SORTORDER_CREATED_ASC:
                return 'fp.created';
            case self::SORTORDER_REPLIES_DESC:
            case self::SORTORDER_REPLIES_ASC:
                return 'replycount';
            default:
                global $CFG;
                $alias = $this->get_table_alias();
                $field = "{$alias}.timemodified";
                if (!empty($CFG->forum_enabletimedposts)) {
                    return "CASE WHEN {$field} < {$alias}.timestart THEN {$alias}.timestart ELSE {$field} END";
                }
                return $field;
        }
    }
protected function get_keyfield ( ? int $ sortmethod ) : string { switch ( $ sortmethod ) { case self :: SORTORDER_CREATED_DESC : case self :: SORTORDER_CREATED_ASC : return 'fp.created' ; case self :: SORTORDER_REPLIES_DESC : case self :: SORTORDER_REPLIES_ASC : return 'replycount' ; default : global $ CFG ; $ alias = $ this -> get_table_alias ( ) ; $ field = "{$alias}.timemodified" ; if ( ! empty ( $ CFG -> forum_enabletimedposts ) ) { return "CASE WHEN {$field} < {$alias}.timestart THEN {$alias}.timestart ELSE {$field} END" ; } return $ field ; } }
Get the field to sort by.

@param int|null $sortmethod
@return string
Get the field to sort by .