code: def test_maintain_order_after_sampling() -> None:
      # internally samples cardinality
      # check if the maintain_order kwarg is dispatched
      df = pl.DataFrame(
          {
              "type": ["A", "B", "C", "D", "A", "B", "C", "D"],
              "value": [1, 3, 2, 3, 4, 5, 3, 4],
          }
      )
  
      result = df.group_by("type", maintain_order=True).agg(
          pl.col("value").sum()
      )
      expected = {"type": ["A", "B", "C", "D"], "value": [5, 8, 5, 7]}
      assert result.to_dict(as_series=False) == expected
  
imports: from __future__ import annotations
  from datetime import datetime, timedelta
  from typing import Any
  import numpy
  import pandas
  import polars
  from polars.testing import assert_frame_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_maintain_order_after_sampling() without return types