<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_sorted_series_files(self, startpath="", series_number=None, return_files_with_info=False, sort_keys="SliceLocation", return_files=True, remove_doubled_slice_locations=True):
 """ Function returns sorted list of dicom files. File paths are organized by SeriesUID, StudyUID and FrameUID :param startpath: path prefix. E.g. "~/data" :param series_number: ID of series used for filtering the data :param return_files_with_info: return more complex information about sorted files :param return_files: return simple list of sorted files :type sort_keys: One key or list of keys used for sorting method by the order of keys. """

        dcmdir = self.files_with_info[:]

        # select sublist with SeriesNumber
        if series_number is not None:
            dcmdir = [
                line for line in dcmdir if line['SeriesNumber'] == series_number
            ]
        dcmdir = sort_list_of_dicts(dcmdir, keys=sort_keys)

        logger.debug('SeriesNumber: ' + str(series_number))

        if remove_doubled_slice_locations:
            dcmdir = self._remove_doubled_slice_locations(dcmdir)

        filelist = []
        for onefile in dcmdir:
            filelist.append(os.path.join(startpath,
                                         self.dirpath, onefile['filename']))
            # head, tail = os.path.split(onefile['filename'])


        retval = []
        if return_files:
            retval.append(filelist)
        if return_files_with_info:
            retval.append(dcmdir)

        if len(retval) == 0:
            retval = None
        elif len(retval) == 1:
            retval = retval[0]
        else:
            retval = tuple(retval)

        return retval