<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dispatchlist(self, *, author=None, category=None, subcategory=None, sort='new'):
 """Find dispatches by certain criteria. Parameters author : str Name of the nation authoring the dispatch. category : str Dispatch's primary category. subcategory : str Dispatch's secondary category. sort : str Sort order, 'new' or 'best'. Returns ------- an :class:`ApiQuery` of a list of :class:`DispatchThumbnail` """

        params = {'sort': sort}
        if author:
            params['dispatchauthor'] = author
        # Here we do need to ensure that our categories are valid, cause
        # NS just ignores the categories it doesn't recognise and returns
        # whatever it feels like.
        if category and subcategory:
            if (category not in dispatch_categories or
                    subcategory not in dispatch_categories[category]):
                raise ValueError('Invalid category/subcategory')
            params['dispatchcategory'] = f'{category}:{subcategory}'
        elif category:
            if category not in dispatch_categories:
                raise ValueError('Invalid category')
            params['dispatchcategory'] = category
        else:
            raise ValueError('Cannot request subcategory without category')

        @api_query('dispatchlist', **params)
        async def result(_, root):
            return [
                DispatchThumbnail._from_elem(elem)
                for elem in root.find('DISPATCHLIST')
            ]
        return result(self)