code: def sorted_analyses(self, analyses):
          analyses = sorted(analyses, key=lambda an: an.getRequestID())
          def sorted_by_sortkey(objs):
              return sorted(objs, key=lambda an: an.getPrioritySortkey())
          current_sample_id = None
          current_analyses = []
          sorted_analyses = []
          for analysis in analyses:
              sample_id = analysis.getRequestID()
              if sample_id and current_sample_id != sample_id:
                  current_analyses = sorted_by_sortkey(current_analyses)
                  sorted_analyses.extend(current_analyses)
                  current_sample_id = sample_id
                  current_analyses = []
              current_analyses.append(analysis)
              continue
          current_analyses = sorted_by_sortkey(current_analyses)
          sorted_analyses.extend(current_analyses)
          return sorted_analyses