code: def test_categorical_lexical_ordering_after_concat() -> None:
      with pl.StringCache():
          ldf1 = (
              pl.DataFrame(
                  [
                      pl.Series("key1", [8, 5]),
                      pl.Series("key2", ["fox", "baz"]),
                  ]
              )
              .lazy()
              .with_columns(
                  pl.col("key2").cast(pl.Categorical("lexical"))
              )
          )
          ldf2 = (
              pl.DataFrame(
                  [
                      pl.Series("key1", [6, 8, 6]),
                      pl.Series("key2", ["fox", "foo", "bar"]),
                  ]
              )
              .lazy()
              .with_columns(
                  pl.col("key2").cast(pl.Categorical("lexical"))
              )
          )
          df = pl.concat([ldf1, ldf2]).select(pl.col("key2")).collect()
  
          assert df.sort("key2").to_dict(as_series=False) == {
              "key2": ["bar", "baz", "foo", "fox", "fox"]
          }
  
file_path: polars/py-polars/tests/unit/namespaces/test_categorical.py
imports: import polars
  from polars.testing import assert_frame_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_categorical_lexical_ordering_after_concat() without return types