nodes: 0, module; 1, function_definition; 2, function_name:merge_range_pairs; 3, parameters; 4, block; 5, identifier:prs; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, while_statement; 13, return_statement; 14, string; 15, assignment; 16, assignment; 17, assignment; 18, assignment; 19, assignment; 20, comparison_operator:x < len(sprs); 21, block; 22, identifier:new_prs; 23, string_content:Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges.; 24, identifier:new_prs; 25, list; 26, identifier:sprs; 27, list_comprehension; 28, identifier:sprs; 29, call; 30, identifier:merged; 31, False; 32, identifier:x; 33, integer:0; 34, identifier:x; 35, call; 36, expression_statement; 37, expression_statement; 38, for_statement; 39, if_statement; 40, expression_statement; 41, call; 42, for_in_clause; 43, identifier:sorted; 44, argument_list; 45, identifier:len; 46, argument_list; 47, assignment; 48, assignment; 49, identifier:y; 50, call; 51, block; 52, comparison_operator:new_pair not in new_prs; 53, block; 54, assignment; 55, identifier:sorted; 56, argument_list; 57, identifier:p; 58, identifier:prs; 59, identifier:sprs; 60, identifier:sprs; 61, identifier:newx; 62, binary_operator:x + 1; 63, identifier:new_pair; 64, call; 65, identifier:range; 66, argument_list; 67, if_statement; 68, identifier:new_pair; 69, identifier:new_prs; 70, expression_statement; 71, identifier:x; 72, identifier:newx; 73, identifier:p; 74, identifier:x; 75, integer:1; 76, identifier:list; 77, argument_list; 78, binary_operator:x + 1; 79, call; 80, comparison_operator:new_pair[0] <= sprs[y][0] - 1 <= new_pair[1]; 81, block; 82, call; 83, subscript; 84, identifier:x; 85, integer:1; 86, identifier:len; 87, argument_list; 88, subscript; 89, binary_operator:sprs[y][0] - 1; 90, subscript; 91, expression_statement; 92, expression_statement; 93, expression_statement; 94, attribute; 95, argument_list; 96, identifier:sprs; 97, identifier:x; 98, identifier:sprs; 99, identifier:new_pair; 100, integer:0; 101, subscript; 102, integer:1; 103, identifier:new_pair; 104, integer:1; 105, assignment; 106, assignment; 107, assignment; 108, identifier:new_prs; 109, identifier:append; 110, identifier:new_pair; 111, subscript; 112, integer:0; 113, subscript; 114, call; 115, subscript; 116, call; 117, identifier:newx; 118, binary_operator:y + 1; 119, identifier:sprs; 120, identifier:y; 121, identifier:new_pair; 122, integer:0; 123, identifier:min; 124, argument_list; 125, identifier:new_pair; 126, integer:1; 127, identifier:max; 128, argument_list; 129, identifier:y; 130, integer:1; 131, subscript; 132, subscript; 133, subscript; 134, subscript; 135, identifier:new_pair; 136, integer:0; 137, subscript; 138, integer:0; 139, identifier:new_pair; 140, integer:1; 141, subscript; 142, integer:1; 143, identifier:sprs; 144, identifier:y; 145, identifier:sprs; 146, identifier:y
code: def merge_range_pairs(prs):
      '''Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges.'''
      new_prs = []
      sprs = [sorted(p) for p in prs]
      sprs = sorted(sprs)
      merged = False
      x = 0
      while x < len(sprs):
          newx = x + 1
          new_pair = list(sprs[x])
          for y in range(x + 1, len(sprs)):
              if new_pair[0] <= sprs[y][0] - 1 <= new_pair[1]:
                  new_pair[0] = min(new_pair[0], sprs[y][0])
                  new_pair[1] = max(new_pair[1], sprs[y][1])
                  newx = y + 1
          if new_pair not in new_prs:
              new_prs.append(new_pair)
          x = newx
      return new_prs