Sorted user recipes in serialize_collection

This commit is contained in:
Starson17 2010-11-10 11:58:15 -05:00
parent 4ecd8d2c6d
commit 62759f161b

View File

@ -61,8 +61,8 @@ def serialize_recipe(urn, recipe_class):
def serialize_collection(mapping_of_recipe_classes): def serialize_collection(mapping_of_recipe_classes):
collection = E.recipe_collection() collection = E.recipe_collection()
for urn, recipe_class in mapping_of_recipe_classes.items(): for urn in sorted(mapping_of_recipe_classes.keys(), key = lambda key: mapping_of_recipe_classes[key].title):
recipe = serialize_recipe(urn, recipe_class) recipe = serialize_recipe(urn, mapping_of_recipe_classes[urn])
collection.append(recipe) collection.append(recipe)
collection.set('count', str(len(collection))) collection.set('count', str(len(collection)))
return etree.tostring(collection, encoding='utf-8', xml_declaration=True, return etree.tostring(collection, encoding='utf-8', xml_declaration=True,