code: def filter_and_order_column_titles(
      human_labels: List[str],
      stepwise_labels: List[str],
  ) -> List[str]:
      # columns
      chain_label_names = [
          h for h in human_labels if h.startswith("0_full")
      ]
      agg_stepwise_label_names = [
          s for s in stepwise_labels if is_label_stepwise_aggregate(s)
      ]
      stepwise_labels_not_numbered = [
          s for s in stepwise_labels if not contains_number(s)
      ]
      (
          agg_stepwise_agg_label_names,
          agg_stepwise_raw_label_names,
      ) = split_list(
          agg_stepwise_label_names,
          lambda n: "S-" in n and not n.startswith("middle_"),
      )
      last_step_labels = [
          l
          for l in stepwise_labels_not_numbered
          if l.startswith("last_")
      ]
      # pull the "any step" aggregation labels to the front, with *_any_issue labels first
      agg_rating_labels = [
          l
          for l in human_labels
          if l.startswith("any_") and not l.startswith("any_middle_")
      ]
      top_agg_rating_labels = [
          "ANY_ERROR",
          "any_step_any_issue",
      ]
      agg_rating_labels = [
          l for l in agg_rating_labels if l not in top_agg_rating_labels
      ]
  
      # then come the others
      non_agg_rating_labels = [
          l
          for l in stepwise_labels_not_numbered
          if l not in agg_rating_labels
      ]
      seq_aggregates = [
          "ANY_ERROR",
          "0_full_overall_result"
          if "0_full_overall_result" in human_labels
          else "0_full_newOverall_result",
          "0_full_coherent_result"
          if "0_full_coherent_result" in human_labels
          else "0_full_newCoherent_result",
      ]
      column_titles = ordered_union(
          [
              seq_aggregates,
              chain_label_names,
              top_agg_rating_labels,
              agg_stepwise_agg_label_names,
              last_step_labels,
              agg_rating_labels,
              agg_stepwise_label_names,
              non_agg_rating_labels,
          ]
      )
      return column_titles
  
imports: import argparse
  from collections import defaultdict
  import csv
  import math
  import os
  import pathlib
  from typing import Dict, Iterable, List, Optional, Set, Tuple, Union
  import pandas
  from projects.roscoe.meta_evaluation.correlations import Analyzer
  from projects.roscoe.score import ROSCOE_SA, ROSCOE_SS, ROSCOE_LI, ROSCOE_LC, SUPERVISED_SCORES, UNSUPERVISED_SCORES
  from projects.roscoe.utils import assert_all_elements_same_length, ordered_union, split_list
  from projects.roscoe.meta_evaluation.table_file_writing import ANNOTATION_COLUMN_ORDER, COLUMN_RENAMES, MODELS, ROSCOE_SECTIONS, STEP_COLUMN_RENAMES, section_rows, write_every_dataset_summary_table_tex, write_every_dataset_final_summary_table_tex, write_granular_summary_tex
label_desc: Use image node_id 20 for calling a global function with example usage: filter_and_order_column_titles(human_labels, stepwise_labels) and returns: column_titles