diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 9551a2b434..dbc28a4200 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -822,7 +822,7 @@ class Cache(object): get_metadata, lang_map, all_book_ids) except KeyError: if field == 'id': - ans = {bid:bid for bid in ids_to_sort} + ans = {bid:bid for bid in all_book_ids} else: ans = virtual_fields[fm.get(field, field)].sort_keys_for_books( get_metadata, lang_map, all_book_ids)