diff --git a/pycroft/lib/facilities.py b/pycroft/lib/facilities.py index 8e00fdd1d..866cb6ea8 100644 --- a/pycroft/lib/facilities.py +++ b/pycroft/lib/facilities.py @@ -69,6 +69,7 @@ def get_overcrowded_rooms(building_id: int = None) -> dict[int, list[User]]: ) users = session.session.scalars(stmt).unique().all() + users = sorted(users, key=lambda u: u.room.id) return {k: list(v) for k, v in groupby(users, lambda u: u.room.id)}