web2pyに次のコードがあります。テーブルにあるアイテムの種類と、それぞれの数の数を取得しようとしています。
count = db.table.field1.count()
rows=db((some criteria).select(db.table.field2, count, groupby=db.table.field2)
print rows
これのプリントは次のとおりです。
table.field2, COUNT(table.field1)
4,3
6,4
9,2
ここで、count フィールドで高いものから低いものへと並べ替えたいので、結果は次のようになります。
6,4
4,3
9,2
それを行う最良の方法は何ですか?rows=rows.sort(lambda row: row.COUNT(table.field1)) はうまくいきませんでした。