code: def chrom_sorted(in_chroms):
      
      in_chroms.sort()
      canonicals = [str(c) for c in range(1, 23)] + ['X', 'Y', 'M', 'MT']
      canonical_chr = ['chr' + c for c in canonicals]
      out_chroms_dict = {
          'can': [c for c in in_chroms if c in canonicals],
          'can_chr': [c for c in in_chroms if c in canonical_chr],
          'others': [c for c in in_chroms if c not in canonicals + canonical_chr]}
  
      assert not (out_chroms_dict['can'] and out_chroms_dict['can_chr'])
      assert not ('M' in out_chroms_dict['can']and 'MT' in out_chroms_dict['can'])
      assert not ('chrM' in out_chroms_dict['can_chr'] and 'chrMT' in out_chroms_dict['can_chr'])
  
      out_chroms_dict['can'] = canonical_chrom_sorted(out_chroms_dict['can'])
      out_chroms_dict['can_chr'] = canonical_chrom_sorted(out_chroms_dict['can_chr'])
  
      out_chroms = out_chroms_dict['can'] or out_chroms_dict['can_chr']
      out_chroms.extend(out_chroms_dict['others'])
      return out_chroms
docs: Sort a list of chromosomes in the order 1..22, X, Y, M, <others in alphabetical order>.
  
      :param list in_chroms: Input chromosomes
      :return: Sorted chromosomes
      :rtype: list[str]