diff --git a/src/bot/message_handlers.py b/src/bot/message_handlers.py index d7a8a85..4212dd6 100644 --- a/src/bot/message_handlers.py +++ b/src/bot/message_handlers.py @@ -540,7 +540,6 @@ async def _export2( ) tasks.append(loop.run_in_executor(pool, function)) accounts = await asyncio.gather(*tasks) - accounts.sort(key=lambda account: account.name) json_io = accounts_to_json(accounts) await bot.send_document( mes.chat.id, diff --git a/src/db/get.py b/src/db/get.py index bf06528..26d74cf 100644 --- a/src/db/get.py +++ b/src/db/get.py @@ -36,8 +36,12 @@ def get_account_names( def get_accounts(engine: Engine, user_id: int) -> list[models.Account]: """Returns a list of accounts of a user""" - statement = sqlmodel.select(models.Account).where( - models.Account.user_id == user_id, + statement = ( + sqlmodel.select(models.Account) + .where( + models.Account.user_id == user_id, + ) + .order_by(models.Account.name) ) with sqlmodel.Session(engine) as session: result = session.exec(statement).fetchall()