code: def _prepare_bam_file(bam_file, tmp_dir, config):
      sort_mode = _get_sort_order(bam_file, config)
      if sort_mode != "queryname":
          bam_file = sort(bam_file, config, "queryname")
      return bam_file