code: def sort_features_by_priority(
      features: List[str],
      prev_importance_df: pd.DataFrame,
      using_prev_fit_fi: Set[str],
  ) -> List[str]:
      """
      Return a list of features sorted by feature importance calculation priority in ascending order.
      If prev_importance_df does not exist and not using noise prune_threshold, return the original list.
      If prev_importance_df exists, features whose importance scores have never been calculated are
      prioritized first followed by features whose importance scores are from previous fitted models and
      lastly the rest of the features sorted by previous importance scores estimates in ascending order. If using
      noise prune_threshold, noise columns are prioritized first since their scores are needed to determine
      the pruning threshold.
      """
      is_first_run = prev_importance_df is None
      if not is_first_run:
          prev_deleted_features = [
              feature
              for feature in prev_importance_df.index
              if feature not in features
          ]
          prev_importance_df = prev_importance_df.drop(
              prev_deleted_features
          )
          unevaluated_rows = prev_importance_df[
              prev_importance_df["importance"].isna()
          ]
          prev_fit_evaluated_rows = prev_importance_df[
              ~(prev_importance_df["importance"].isna())
              & (prev_importance_df.index.isin(using_prev_fit_fi))
          ].sort_values(by="importance")
          curr_fit_evaluated_rows = prev_importance_df[
              ~(prev_importance_df["importance"].isna())
              & ~(prev_importance_df.index.isin(using_prev_fit_fi))
          ].sort_values(by="importance")
          features = (
              unevaluated_rows.index.tolist()
              + prev_fit_evaluated_rows.index.tolist()
              + curr_fit_evaluated_rows.index.tolist()
          )
      return features
  
imports: import logging
  import time
  import traceback
  import uuid
  from copy import deepcopy
  from typing import List, Set, Tuple, Union
  import numpy
  import pandas
  from autogluon.common.features.types import R_FLOAT
  from ..models.abstract.abstract_model import AbstractModel
  from ..models.ensemble.bagged_ensemble_model import BaggedEnsembleModel
  from ..utils.exceptions import TimeLimitExceeded
  from ..utils.utils import generate_train_test_split, unevaluated_fi_df_template
label_desc: Use image node_id 3 for calling a global function with example usage: sort_features_by_priority(features, prev_importance_df, using_prev_fit_fi) and returns: features