nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, expression_statement; 15, comment:"""
          Sort the fragments in the list.
  
          :raises ValueError: if there is a fragment which violates
                              the list constraints
          """; 16, attribute; 17, block; 18, call; 19, assignment; 20, call; 21, call; 22, identifier:i; 23, call; 24, block; 25, call; 26, assignment; 27, identifier:self; 28, identifier:is_guaranteed_sorted; 29, expression_statement; 30, return_statement; 31, attribute; 32, argument_list; 33, attribute; 34, call; 35, attribute; 36, argument_list; 37, attribute; 38, argument_list; 39, identifier:range; 40, argument_list; 41, expression_statement; 42, expression_statement; 43, if_statement; 44, attribute; 45, argument_list; 46, attribute; 47, True; 48, call; 49, identifier:self; 50, identifier:log; 51, string:u"Sorting..."; 52, identifier:self; 53, identifier:__fragments; 54, identifier:sorted; 55, argument_list; 56, identifier:self; 57, identifier:log; 58, string:u"Sorting... done"; 59, identifier:self; 60, identifier:log; 61, string:u"Checking relative positions..."; 62, binary_operator:len(self) - 1; 63, assignment; 64, assignment; 65, comparison_operator:current_interval.relative_position_of(next_interval) not in self.ALLOWED_POSITIONS; 66, block; 67, identifier:self; 68, identifier:log; 69, string:u"Checking relative positions... done"; 70, identifier:self; 71, identifier:__sorted; 72, attribute; 73, argument_list; 74, attribute; 75, call; 76, integer:1; 77, identifier:current_interval; 78, attribute; 79, identifier:next_interval; 80, attribute; 81, call; 82, attribute; 83, expression_statement; 84, expression_statement; 85, expression_statement; 86, expression_statement; 87, identifier:self; 88, identifier:log; 89, string:u"Already sorted, returning"; 90, identifier:self; 91, identifier:__fragments; 92, identifier:len; 93, argument_list; 94, subscript; 95, identifier:interval; 96, subscript; 97, identifier:interval; 98, attribute; 99, argument_list; 100, identifier:self; 101, identifier:ALLOWED_POSITIONS; 102, call; 103, call; 104, call; 105, call; 106, identifier:self; 107, identifier:self; 108, identifier:i; 109, identifier:self; 110, binary_operator:i + 1; 111, identifier:current_interval; 112, identifier:relative_position_of; 113, identifier:next_interval; 114, attribute; 115, argument_list; 116, attribute; 117, argument_list; 118, attribute; 119, argument_list; 120, attribute; 121, argument_list; 122, identifier:i; 123, integer:1; 124, identifier:self; 125, identifier:log; 126, string:u"Found overlapping fragments:"; 127, identifier:self; 128, identifier:log; 129, list; 130, identifier:self; 131, identifier:log; 132, list; 133, identifier:self; 134, identifier:log_exc; 135, string:u"The list contains two fragments overlapping in a forbidden way"; 136, None; 137, True; 138, identifier:ValueError; 139, string:u"  Index %d => %s"; 140, identifier:i; 141, identifier:current_interval; 142, string:u"  Index %d => %s"; 143, binary_operator:i + 1; 144, identifier:next_interval; 145, identifier:i; 146, integer:1
code: def sort(self):
          """
          Sort the fragments in the list.
  
          :raises ValueError: if there is a fragment which violates
                              the list constraints
          """
          if self.is_guaranteed_sorted:
              self.log(u"Already sorted, returning")
              return
          self.log(u"Sorting...")
          self.__fragments = sorted(self.__fragments)
          self.log(u"Sorting... done")
          self.log(u"Checking relative positions...")
          for i in range(len(self) - 1):
              current_interval = self[i].interval
              next_interval = self[i + 1].interval
              if current_interval.relative_position_of(next_interval) not in self.ALLOWED_POSITIONS:
                  self.log(u"Found overlapping fragments:")
                  self.log([u"  Index %d => %s", i, current_interval])
                  self.log([u"  Index %d => %s", i + 1, next_interval])
                  self.log_exc(u"The list contains two fragments overlapping in a forbidden way", None, True, ValueError)
          self.log(u"Checking relative positions... done")
          self.__sorted = True