Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 处理四位数:memcache从最小到最大排序1000到150_Python_Google App Engine_Memcached - Fatal编程技术网

Python 处理四位数:memcache从最小到最大排序1000到150

Python 处理四位数:memcache从最小到最大排序1000到150,python,google-app-engine,memcached,Python,Google App Engine,Memcached,在应用程序引擎中,我检索存储在memcache中的项目列表: items = memcache.get("ITEMS") 并按数量和价格对其进行分类: items.sort(key = lambda x:(x.price, x.amount)) 当金额为三位数时,大多数情况下都有效。但是,当我有两个项目,金额分别为150和1000,价格相同时,1000的条目优先于另一个条目。如何修复此问题?已修复: items.sort(key = lambda x:((float)(x.price), (

在应用程序引擎中,我检索存储在memcache中的项目列表:

items = memcache.get("ITEMS")
并按数量和价格对其进行分类:

items.sort(key = lambda x:(x.price, x.amount))
当金额为三位数时,大多数情况下都有效。但是,当我有两个项目,金额分别为150和1000,价格相同时,1000的条目优先于另一个条目。如何修复此问题?

已修复:

items.sort(key = lambda x:((float)(x.price), (int)(x.amount)))

提问和回答:问题:回答: