def __init__(self, sorter, mappings=None):
if mappings is None:<EOL><INDENT>mappings = []<EOL><DEDENT>if '<STR_LIT>' in sorter:<EOL><INDENT>self._fields = sorter['<STR_LIT>'].split('<STR_LIT:U+002C>')<EOL>if '<STR_LIT>' in sorter:<EOL><INDENT>self._orders = sorter['<STR_LIT>'].split('<STR_LIT:U+002C>')<EOL>if len(self._orders) == <NUM_LIT:1>:<EOL><INDENT>self._orders *= len(self._fields)<EOL><DEDENT>elif len(self._orders) != len(self._fields):<EOL><INDENT>raise Exception(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._orders = [DEFAULT_SORT_ORDER] * len(self._fields)<EOL><DEDENT>self._enabled = True<EOL><DEDENT>else:<EOL><INDENT>self._enabled = False<EOL><DEDENT>self._mappings = mappings<EOL>
sorter = {'sortby': string, 'sort': string}
    sortby - string of comma-separated column names by which you want to order
    sort - string of comma-separated values 'ASC'/'DESC' (order direction) which
            set order direction to corresponding columns from sorter['sortby'] string
    notes: - if 'sortby' key is not in sorter, no sorting will be applied to query
           - if 'sort' key is not in sorter, DEFAULT_SORT_ORDER will be applied to
             all columns from sorter['sortby']
           - if sorter['sort'] == 'ASC' / 'DESC' (contains only one order direction),
             this direction will be applied to all columns from sorter['sortby']
           - if you want to order only by one column, simply put
             sorter['sortby'] = '<column_name>' - without comma at the end of
             the string
mappings dict - maps column names from sorter['sortby'] to column attributes names of
                objects (see example)
              - if the column names from sorter['sortby'] is equal to the name
                of column attribute, it doesn`t have to be mentioned in mappings

Example:
    sorter = {'sortby': 'firstname,state,sport', 'sort': 'ASC'}

    mappings = {
        'state': (State, 'name_sk'),
        'sport': (Sport, 'name'),
    }