code: def buildSubMenu(self, names, source, sort=True):
      # in Qt6 we could have used Qt.ConnectionType.SingleShotConnection
      menu = self.sender()
      menu.aboutToShow.disconnect()
  
      if sort:
          pattern = re.compile(r"(\d+)")
          key = lambda x: [
              int(c) if c.isdigit() else c for c in pattern.split(x)
          ]
          names = sorted(names, key=key)
  
      for name in names:
          if source == "preset-gradient":
              cmap = preset_gradient_to_colormap(name)
          else:
              cmap = colormap.get(name, source=source)
          act = QtWidgets.QWidgetAction(menu)
          act.setData((name, source))
          act.setDefaultWidget(buildMenuEntryWidget(cmap, name))
          menu.addAction(act)
  
imports: import importlib.util
  import re
  import numpy
  from ..None import colormap
  from ..None import functions
  from ..graphicsItems.GradientPresets import Gradients
  from ..Qt import QtCore, QtGui, QtWidgets
label_desc: Use image node_id 8 for calling the ColorMapMenu obj's underlying member method code with example usage: obj.buildSubMenu(names, source, sort) without return types