<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_sort_by(self, element, decl, pseudo):
 """Implement sort-by declaration - pre-match."""

        if ',' in decl.value:
            css, flags = split(decl.value, ',')
        else:
            css = decl.value
            flags = None
        sort = css_to_func(serialize(css), serialize(flags or ''),
                           self.css_namespaces, self.state['lang'])
        step = self.state[self.state['current_step']]

        target = self.current_target()
        target.sort = sort
        target.lang = self.state['lang']
        target.isgroup = False
        target.groupby = None
        #  Find current target, set its sort as well
        for pos, action in \
                enumerate(reversed(step['actions'])):
            if action[0] == 'target' and \
                    action[1].tree == element.etree_element:
                action[1].sort = sort
                action[1].isgroup = False
                action[1].groupby = None
                break