nodes: 0, module; 1, function_definition; 2, function_name:sort_seq_records; 3, parameters; 4, block; 5, identifier:self; 6, identifier:seq_records; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, for_statement; 17, return_statement; 18, comment:"""Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code.
  
          The dashes in taxon names need to be converted to underscores so the
          dataset will be accepted by Biopython to do format conversions.
  
          """; 19, identifier:seq_record; 20, identifier:seq_records; 21, block; 22, assignment; 23, assignment; 24, call; 25, assignment; 26, assignment; 27, call; 28, assignment; 29, identifier:gene_code; 30, identifier:sorted_gene_codes; 31, block; 32, identifier:sorted_seq_records; 33, expression_statement; 34, identifier:unsorted_gene_codes; 35, call; 36, identifier:sorted_gene_codes; 37, call; 38, attribute; 39, argument_list; 40, identifier:unsorted_voucher_codes; 41, call; 42, identifier:sorted_voucher_codes; 43, call; 44, attribute; 45, argument_list; 46, identifier:sorted_seq_records; 47, list; 48, for_statement; 49, assignment; 50, identifier:set; 51, argument_list; 52, identifier:list; 53, argument_list; 54, identifier:sorted_gene_codes; 55, identifier:sort; 56, keyword_argument; 57, identifier:set; 58, argument_list; 59, identifier:list; 60, argument_list; 61, identifier:sorted_voucher_codes; 62, identifier:sort; 63, keyword_argument; 64, identifier:voucher_code; 65, identifier:sorted_voucher_codes; 66, block; 67, attribute; 68, call; 69, list_comprehension; 70, identifier:unsorted_gene_codes; 71, identifier:key; 72, lambda; 73, list_comprehension; 74, identifier:unsorted_voucher_codes; 75, identifier:key; 76, lambda; 77, for_statement; 78, identifier:seq_record; 79, identifier:voucher_code; 80, attribute; 81, argument_list; 82, attribute; 83, for_in_clause; 84, lambda_parameters; 85, call; 86, attribute; 87, for_in_clause; 88, lambda_parameters; 89, call; 90, identifier:seq_record; 91, identifier:seq_records; 92, block; 93, attribute; 94, identifier:replace; 95, string:"-"; 96, string:"_"; 97, identifier:i; 98, identifier:gene_code; 99, identifier:i; 100, identifier:seq_records; 101, identifier:x; 102, attribute; 103, argument_list; 104, identifier:i; 105, identifier:voucher_code; 106, identifier:i; 107, identifier:seq_records; 108, identifier:x; 109, attribute; 110, argument_list; 111, expression_statement; 112, if_statement; 113, identifier:seq_record; 114, identifier:voucher_code; 115, identifier:x; 116, identifier:lower; 117, identifier:x; 118, identifier:lower; 119, assignment; 120, identifier:should_be_done; 121, block; 122, identifier:should_be_done; 123, parenthesized_expression; 124, expression_statement; 125, boolean_operator; 126, call; 127, comparison_operator:seq_record.gene_code == gene_code; 128, comparison_operator:seq_record.voucher_code == voucher_code; 129, attribute; 130, argument_list; 131, attribute; 132, identifier:gene_code; 133, attribute; 134, identifier:voucher_code; 135, identifier:sorted_seq_records; 136, identifier:append; 137, identifier:seq_record; 138, identifier:seq_record; 139, identifier:gene_code; 140, identifier:seq_record; 141, identifier:voucher_code
code: def sort_seq_records(self, seq_records):
          """Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code.
  
          The dashes in taxon names need to be converted to underscores so the
          dataset will be accepted by Biopython to do format conversions.
  
          """
          for seq_record in seq_records:
              seq_record.voucher_code = seq_record.voucher_code.replace("-", "_")
  
          unsorted_gene_codes = set([i.gene_code for i in seq_records])
          sorted_gene_codes = list(unsorted_gene_codes)
          sorted_gene_codes.sort(key=lambda x: x.lower())
  
          unsorted_voucher_codes = set([i.voucher_code for i in seq_records])
          sorted_voucher_codes = list(unsorted_voucher_codes)
          sorted_voucher_codes.sort(key=lambda x: x.lower())
  
          sorted_seq_records = []
          for gene_code in sorted_gene_codes:
              for voucher_code in sorted_voucher_codes:
                  for seq_record in seq_records:
                      should_be_done = (
                          seq_record.gene_code == gene_code and
                          seq_record.voucher_code == voucher_code
                      )
                      if should_be_done:
                          sorted_seq_records.append(seq_record)
          return sorted_seq_records