code: def test_log_metrics_column_order_sorted(tmp_path):
      """Test that the columns in the output metrics file are sorted by name."""
      logger = CSVLogger(tmp_path)
      logger.log_metrics({"c": 0.1})
      logger.log_metrics({"c": 0.2})
      logger.log_metrics({"b": 0.3})
      logger.log_metrics({"a": 0.4})
      logger.save()
      logger.log_metrics({"d": 0.5})
      logger.save()
  
      path_csv = os.path.join(
          logger.log_dir, _ExperimentWriter.NAME_METRICS_FILE
      )
      with open(path_csv) as fp:
          lines = fp.readlines()
  
      assert lines[0].strip() == "a,b,c,d,step"
  
file_path: pytorch-lightning/tests/tests_fabric/loggers/test_csv.py
imports: import os
  from unittest.mock import MagicMock
  import pytest
  import torch
  from lightning.fabric.loggers import CSVLogger
  from lightning.fabric.loggers.csv_logs import _ExperimentWriter
label_desc: Use image node_id 14 for calling a global function with example usage: test_log_metrics_column_order_sorted(tmp_path) without return types