diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 283773ac58..28058d7e8a 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -223,7 +223,7 @@ class Cache(object): good_formats = None else: mi.format_metadata = FormatMetadata(self, book_id, formats) - good_formats = FormatsList(formats, mi.format_metadata) + good_formats = FormatsList(sorted(formats), mi.format_metadata) # These three attributes are returned by the db2 get_metadata(), # however, we dont actually use them anywhere other than templates, so # they have been removed, to avoid unnecessary overhead. The templates diff --git a/src/calibre/db/lazy.py b/src/calibre/db/lazy.py index 166627c438..73260c8ae7 100644 --- a/src/calibre/db/lazy.py +++ b/src/calibre/db/lazy.py @@ -175,7 +175,7 @@ def fmt_getter(field): if m: format_metadata[fmt] = m if field == 'formats': - return list(format_metadata) or None + return sorted(format_metadata) or None return format_metadata return func diff --git a/src/calibre/db/tests/reading.py b/src/calibre/db/tests/reading.py index 66b1dacec4..56866f5aa7 100644 --- a/src/calibre/db/tests/reading.py +++ b/src/calibre/db/tests/reading.py @@ -478,7 +478,7 @@ class ReadingTest(BaseTest): for field in STANDARD_METADATA_FIELDS | {'#series_index'}: f = lambda x: x if field == 'formats': - f = lambda x: x if x is None else set(x) + f = lambda x: x if x is None else tuple(x) self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)), 'Standard field: %s not the same for book %s' % (field, book_id)) self.assertEqual(mi.format_field(field), pmi.format_field(field),