code: def sort_by_f1(docs):
      for i in range(len(docs)):
          doc = docs[i]
          generated_field = doc["generated"]
          ground_truth_field = doc["ground_truth"]
          generated_field = remove_punctation(generated_field.lower())
          ground_truth_field = remove_punctation(
              ground_truth_field.lower()
          )
          p, r, f1 = DialogueGenerationMetrics._get_one_f1(
              generated_field, ground_truth_field
          )
          docs[i]["f1"] = f1
          docs[i]["generated"] = generated_field
          docs[i]["ground_truth"] = ground_truth_field
      docs.sort(key=lambda x: x["f1"])
      return docs
  
file_path: NeMo/examples/nlp/dialogue/analyse_prediction_results.py
imports: import argparse
  import json
  import re
  import numpy
  from nemo.collections.nlp.metrics.dialogue_metrics import DialogueGenerationMetrics
label_desc: Use image node_id 4 for calling a global function with example usage: sort_by_f1(docs) and returns: docs