def construct_sort_part(model_cls, part):
 assert part, 'part must be a field name and + or -'
 field = part[:(-1)]
 assert field, 'field is missing'
 direction = part[(-1)]
 assert (direction in ('+', '-')), 'part must end with + or -'
 is_ascending = (direction == '+')
 case_insensitive = beets.config['sort_case_insensitive'].get(bool)
 if (field in model_cls._sorts):
  sort = model_cls._sorts[field](model_cls, is_ascending, case_insensitive)
 elif (field in model_cls._fields):
  sort = query.FixedFieldSort(field, is_ascending, case_insensitive)
 else:
  sort = query.SlowFieldSort(field, is_ascending, case_insensitive)
 return sort

def construct_sort_part ( model_cls , part ) : assert part , 'part must be a field name and + or -' field = part [ : ( - 1 ) ] assert field , 'field is missing' direction = part [ ( - 1 ) ] assert ( direction in ( '+' , '-' ) ) , 'part must end with + or -' is_ascending = ( direction == '+' ) case_insensitive = beets . config [ 'sort_case_insensitive' ] . get ( bool ) if ( field in model_cls . _sorts ) : sort = model_cls . _sorts [ field ] ( model_cls , is_ascending , case_insensitive ) elif ( field in model_cls . _fields ) : sort = query . FixedFieldSort ( field , is_ascending , case_insensitive ) else : sort = query . SlowFieldSort ( field , is_ascending , case_insensitive ) return sort
create a sort from a single string criterion .