code: def sort_device(self):
          self.devices.sort()
          idx = []
          names = []
          for dev in order:
              if dev in all_models:
                  all_dev = list(sorted(all_models[dev].keys()))
                  for item in all_dev:
                      if item in self.devices:
                          idx.append(self.devices.index(item))
                          names.append(item)
              elif dev in self.devices:
                  idx.append(self.devices.index(dev))
                  names.append(dev)
          idx = sorted(idx)
          for id, name in zip(idx, names):
              self.devices[id] = name