code: def test_sorted_flag() -> None:
      s = pl.arange(0, 7, eager=True)
      assert s.flags["SORTED_ASC"]
      assert s.reverse().flags["SORTED_DESC"]
      assert pl.Series([b"a"]).set_sorted().flags["SORTED_ASC"]
      assert (
          pl.Series([date(2020, 1, 1), date(2020, 1, 2)])
          .set_sorted()
          .cast(pl.Datetime)
          .flags["SORTED_ASC"]
      )
  
      # empty
      q = pl.LazyFrame(
          schema={
              "store_id": pl.UInt16,
              "item_id": pl.UInt32,
              "timestamp": pl.Datetime,
          }
      ).sort("timestamp")
  
      assert q.collect()["timestamp"].flags["SORTED_ASC"]
  
      # top-k/bottom-k
      df = pl.DataFrame({"foo": [56, 2, 3]})
      assert df.top_k(2, by="foo")["foo"].flags["SORTED_DESC"]
      assert df.bottom_k(2, by="foo")["foo"].flags["SORTED_ASC"]
  
      # ensure we don't panic for these types
      # struct
      pl.Series([{"a": 1}]).set_sorted(descending=True)
      # list
      pl.Series([[{"a": 1}]]).set_sorted(descending=True)
      # object
      pl.Series([{"a": 1}], dtype=pl.Object).set_sorted(descending=True)
  
imports: from __future__ import annotations
  from datetime import date, datetime
  from typing import Any
  import pytest
  import polars
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 10 for calling a global function with example usage: test_sorted_flag() without return types