code: def group_and_sort_nodes(self):
          if self.node_grouping and not self.node_order:
              if self.group_order == "alphabetically":
                  self.nodes = [
                      n
                      for n, d in sorted(
                          self.graph.nodes(data=True),
                          key=lambda x: x[1][self.node_grouping],
                      )
                  ]
              elif self.group_order == "default":
                  grp = [
                      d[self.node_grouping]
                      for _, d in self.graph.nodes(data=True)
                  ]
                  grp_name = list(unique_everseen(grp))
                  nodes = []
                  for key in grp_name:
                      nodes.extend(
                          [
                              n
                              for n, d in self.graph.nodes(data=True)
                              if key in d.values()
                          ]
                      )
                  self.nodes = nodes
          elif self.node_order and not self.node_grouping:
              self.nodes = [
                  n
                  for n, _ in sorted(
                      self.graph.nodes(data=True),
                      key=lambda x: x[1][self.node_order],
                  )
              ]
          elif self.node_grouping and self.node_order:
              if self.group_order == "alphabetically":
                  self.nodes = [
                      n
                      for n, d in sorted(
                          self.graph.nodes(data=True),
                          key=lambda x: (
                              x[1][self.node_grouping],
                              x[1][self.node_order],
                          ),
                      )
                  ]
              elif self.group_order == "default":
                  grp = [
                      d[self.node_grouping]
                      for _, d in self.graph.nodes(data=True)
                  ]
                  grp_name = list(unique_everseen(grp))
                  nodes = []
                  for key in grp_name:
                      nodes.extend(
                          [
                              n
                              for n, d in sorted(
                                  self.graph.nodes(data=True),
                                  key=lambda x: x[1][self.node_order],
                              )
                              if key in d.values()
                          ]
                      )
                  self.nodes = nodes