Assuming you have a list like the one below
lst = ['AA1111111', 'AD2222222', 'AA3333333', 'AA4444444', 'АВ5555555']
Then you need to get users queryset in the same sequence as their passport data ordered in the list.
You can use this method in making a query that looks like:
SELECT *FROM usersWHERE passport_number IN ('AA1111111', 'AD2222222', 'AA3333333', 'AA4444444', 'АВ5555555')
This will be it new look
Users.objects.none().union( *[User.objects.filter(passport_number=p) for p in lst], all=True)
You can also try this option in sorting it
lst = ['AA1111111', 'AD2222222', 'AA3333333', 'AA4444444', 'АВ5555555']order = {k: i for i, k in enumerate(lst)}items = sorted( Users.objects.filter(passport_number__in=lst), key=lambda x: order.get(x.passport_number),)