code: def test_categorical_lexical_sort() -> None:
      df = pl.DataFrame(
          {"cats": ["z", "z", "k", "a", "b"], "vals": [3, 1, 2, 2, 3]}
      ).with_columns(
          [
              pl.col("cats").cast(pl.Categorical("lexical")),
          ]
      )
  
      out = df.sort(["cats"])
      assert out["cats"].dtype == pl.Categorical
      expected = pl.DataFrame(
          {"cats": ["a", "b", "k", "z", "z"], "vals": [2, 3, 2, 3, 1]}
      )
      assert_frame_equal(
          out.with_columns(pl.col("cats").cast(pl.String)), expected
      )
      out = df.sort(["cats", "vals"])
      expected = pl.DataFrame(
          {"cats": ["a", "b", "k", "z", "z"], "vals": [2, 3, 2, 1, 3]}
      )
      assert_frame_equal(
          out.with_columns(pl.col("cats").cast(pl.String)), expected
      )
      out = df.sort(["vals", "cats"])
  
      expected = pl.DataFrame(
          {"cats": ["z", "a", "k", "b", "z"], "vals": [1, 2, 2, 3, 3]}
      )
      assert_frame_equal(
          out.with_columns(pl.col("cats").cast(pl.String)), expected
      )
  
      s = pl.Series(
          ["a", "c", "a", "b", "a"], dtype=pl.Categorical("lexical")
      )
      assert s.sort().cast(pl.String).to_list() == [
          "a",
          "a",
          "a",
          "b",
          "c",
      ]
  
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 1 for calling a global function with example usage: test_categorical_lexical_sort() without return types