nodes: 0, module; 1, function_definition; 2, function_name:sort_device; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:# idx: the indices of order-sensitive models; 9, comment:# names: an ordered list of order-sensitive models; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, for_statement; 15, comment:"""
          Sort device to follow the order of initialization
  
          :return: None
          """; 16, call; 17, assignment; 18, assignment; 19, identifier:dev; 20, identifier:order; 21, comment:# if ``dev`` in ``order`` is a model file name:; 22, comment:#   initialize the models in alphabet order; 23, block; 24, assignment; 25, pattern_list; 26, call; 27, block; 28, attribute; 29, argument_list; 30, identifier:idx; 31, list; 32, identifier:names; 33, list; 34, if_statement; 35, identifier:idx; 36, call; 37, identifier:id; 38, identifier:name; 39, identifier:zip; 40, argument_list; 41, expression_statement; 42, attribute; 43, identifier:sort; 44, comparison_operator:dev in all_models; 45, block; 46, comment:# if ``dev`` presents as a model name; 47, elif_clause; 48, identifier:sorted; 49, argument_list; 50, identifier:idx; 51, identifier:names; 52, assignment; 53, identifier:self; 54, identifier:devices; 55, identifier:dev; 56, identifier:all_models; 57, expression_statement; 58, for_statement; 59, comparison_operator:dev in self.devices; 60, block; 61, identifier:idx; 62, subscript; 63, identifier:name; 64, assignment; 65, identifier:item; 66, identifier:all_dev; 67, block; 68, identifier:dev; 69, attribute; 70, expression_statement; 71, expression_statement; 72, attribute; 73, identifier:id; 74, identifier:all_dev; 75, call; 76, if_statement; 77, identifier:self; 78, identifier:devices; 79, call; 80, call; 81, identifier:self; 82, identifier:devices; 83, identifier:list; 84, argument_list; 85, comparison_operator:item in self.devices; 86, block; 87, attribute; 88, argument_list; 89, attribute; 90, argument_list; 91, call; 92, identifier:item; 93, attribute; 94, expression_statement; 95, expression_statement; 96, identifier:idx; 97, identifier:append; 98, call; 99, identifier:names; 100, identifier:append; 101, identifier:dev; 102, identifier:sorted; 103, argument_list; 104, identifier:self; 105, identifier:devices; 106, call; 107, call; 108, attribute; 109, argument_list; 110, call; 111, attribute; 112, argument_list; 113, attribute; 114, argument_list; 115, attribute; 116, identifier:index; 117, identifier:dev; 118, attribute; 119, argument_list; 120, identifier:idx; 121, identifier:append; 122, call; 123, identifier:names; 124, identifier:append; 125, identifier:item; 126, identifier:self; 127, identifier:devices; 128, subscript; 129, identifier:keys; 130, attribute; 131, argument_list; 132, identifier:all_models; 133, identifier:dev; 134, attribute; 135, identifier:index; 136, identifier:item; 137, identifier:self; 138, identifier:devices
code: def sort_device(self):
          """
          Sort device to follow the order of initialization
  
          :return: None
          """
  
          self.devices.sort()
          # idx: the indices of order-sensitive models
          # names: an ordered list of order-sensitive models
          idx = []
          names = []
          for dev in order:
              # if ``dev`` in ``order`` is a model file name:
              #   initialize the models in alphabet 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)
  
              # if ``dev`` presents as a model name
              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