In app engine I retrieve a list of items stored in memcache:
items = memcache.get("ITEMS")
and sort them by amount and price:
items.sort(key = lambda x:(x.price, x.amount))
Which works most of the time, when the amount is three digits. However, when I have 2 items with 150 and 1000 amounts for the same price, the entry with 1000 goes before other one. How can I fix this?