code: def _sort_history(history):
      ret = []
      for i, _ in enumerate(history):
          if i in history:
              ret.append(history[i])
          else:
              break
      return ret
  
imports: import logging
  from collections import defaultdict
  from nni import NoMoreTrialError
  from nni.assessor import AssessResult
  from .common import multi_phase_enabled
  from .env_vars import dispatcher_env_vars
  from .msg_dispatcher_base import MsgDispatcherBase
  from .tuner_command_channel import CommandType
  from ..common.serializer import dump, load
  from ..utils import MetricType
label_desc: Use image node_id 1 for calling a global function with example usage: _sort_history(history) and returns: ret