Add sorting transformer for snapshots
diff --git a/CODEOWNERS b/CODEOWNERS
index 50fd48aaee6d3..ca5d0d9e5fde2 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -40,6 +40,11 @@
 # Analytics client
 /localstack/utils/analytics/ @thrau
 
+# Snapshot testing
+/localstack/testing/snapshots/ @dominikschubert @steffyP
+/localstack/testing/pytest/ @dominikschubert
+/localstack/testing/pytest/snapshot.py @dominikschubert @steffyP
+
 ######################
 ### SERVICE OWNERS ###
 ######################
diff --git a/localstack/testing/snapshots/transformer.py b/localstack/testing/snapshots/transformer.py
index 5cd88f825785f..f8285178c5ea3 100644
--- a/localstack/testing/snapshots/transformer.py
+++ b/localstack/testing/snapshots/transformer.py
@@ -3,7 +3,7 @@
 import os
 import re
 from re import Pattern
-from typing import Callable, Optional, Protocol
+from typing import Any, Callable, Optional, Protocol
 
 from jsonpath_ng.ext import parse
 
@@ -203,8 +203,29 @@ def transform(self, input_data: dict, *, ctx: TransformContext) -> dict:
 
 
 class GenericTransformer:
-    def __init__(self, fn: Callable[[dict], dict]):
+    def __init__(self, fn: Callable[[dict, TransformContext], dict]):
         self.fn = fn
 
-    def transform(self, input_data: dict) -> dict:
-        return self.fn(input_data)
+    def transform(self, input_data: dict, *, ctx: TransformContext) -> dict:
+        return self.fn(input_data, ctx)
+
+
+class SortingTransformer:
+    key: str
+    sorting_fn: Callable[[...], Any]
+
+    # TODO: add support for jsonpath
+    def __init__(self, key: str, sorting_fn: Callable[[...], Any]):
+        """Sorts a list at `key` with the given `sorting_fn` (argument for `sorted(list, key=sorting_fn)`)"""
+        self.key = key
+        self.sorting_fn = sorting_fn
+
+    def transform(self, input_data: dict, *, ctx: TransformContext = None) -> dict:
+        for k, v in input_data.items():
+            if k == self.key:
+                if not isinstance(v, list):
+                    raise ValueError("SortingTransformer should only be applied to lists.")
+                input_data[k] = sorted(v, key=self.sorting_fn)
+            elif isinstance(v, dict):
+                input_data[k] = self.transform(v, ctx=ctx)
+        return input_data
diff --git a/tests/unit/utils/testing/test_snapshots.py b/tests/unit/utils/testing/test_snapshots.py
index 7695a7c5a7acd..8bfdbfb1f0fda 100644
--- a/tests/unit/utils/testing/test_snapshots.py
+++ b/tests/unit/utils/testing/test_snapshots.py
@@ -1,7 +1,7 @@
 import pytest
 
 from localstack.testing.snapshots import SnapshotSession
-from localstack.testing.snapshots.transformer import KeyValueBasedTransformer
+from localstack.testing.snapshots.transformer import KeyValueBasedTransformer, SortingTransformer
 from localstack.testing.snapshots.transformer_utility import _resource_name_transformer
 
 
@@ -119,3 +119,34 @@ def test_dot_in_skip_verification_path(self):
 
         skip_path_escaped = ["$..aab", "$..b.'a.aa'"]
         sm._assert_all(skip_verification_paths=skip_path_escaped)
+
+
+def test_sorting_transformer():
+    original_dict = {
+        "a": {
+            "b": [
+                {"name": "c-123"},
+                {"name": "a-123"},
+                {"name": "b-123"},
+            ]
+        },
+        "a2": {
+            "b": [
+                {"name": "b-123"},
+                {"name": "a-123"},
+                {"name": "c-123"},
+            ]
+        },
+    }
+
+    sorted_items = [
+        {"name": "a-123"},
+        {"name": "b-123"},
+        {"name": "c-123"},
+    ]
+
+    transformer = SortingTransformer("b", lambda x: x["name"])
+    transformed_dict = transformer.transform(original_dict)
+
+    assert transformed_dict["a"]["b"] == sorted_items
+    assert transformed_dict["a2"]["b"] == sorted_items

Makes it easier to reliably compare lists via snapshots by sorting them via a transformer instead of having to manually sorting the object before calling `match`.

Usage: 
```python
snapshot.add_transformer(SortingTransformer("Aliases", lambda x: x["Name"]))
 ```
