ctx['valid'] = 0 == len([b for b in to_balance if b.is_questionable])
         ctx['roots'] = observed_tree
         if not raw:
-            ctx['all_accounts'] = accounts_after.keys()
+            ctx['all_accounts'] = sorted(accounts_after.keys())
         self._send_rendered(EDIT_RAW if raw else EDIT_STRUCT, ctx)
 
     def get_ledger(self, ctx: dict[str, Any], raw: bool) -> None:
             for account_name in booking.account_changes:
                 booked_names.add(account_name)
         paths_to_accs: dict[str, Account] = {}
-        for full_name in booked_names:
+        for full_name in sorted(list(booked_names)):
             path = ''
             for step_name in full_name.split(':'):
                 parent_name = path[:]