nodes: 0, module; 1, function_definition; 2, function_name:sorted_migrations; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, return_statement; 9, comment:"""
          Sort migrations if necessary and store in self._sorted_migrations
          """; 10, not_operator; 11, block; 12, attribute; 13, attribute; 14, expression_statement; 15, identifier:self; 16, identifier:_sorted_migrations; 17, identifier:self; 18, identifier:_sorted_migrations; 19, assignment; 20, attribute; 21, call; 22, identifier:self; 23, identifier:_sorted_migrations; 24, identifier:sorted; 25, argument_list; 26, call; 27, comment:# sort on the key... the migration number; 28, keyword_argument; 29, attribute; 30, argument_list; 31, identifier:key; 32, lambda; 33, attribute; 34, identifier:items; 35, lambda_parameters; 36, subscript; 37, identifier:self; 38, identifier:migration_registry; 39, identifier:migration_tuple; 40, identifier:migration_tuple; 41, integer:0
code: def sorted_migrations(self):
          """
          Sort migrations if necessary and store in self._sorted_migrations
          """
          if not self._sorted_migrations:
              self._sorted_migrations = sorted(
                  self.migration_registry.items(),
                  # sort on the key... the migration number
                  key=lambda migration_tuple: migration_tuple[0])
  
          return self._sorted_migrations