i see 2 options:
db.define_table('tabletest', Field('yes', 'integer'), Field('no',
'integer'), Field('tot', 'integer', compute=lambda r:r.yes-r.no))
will compute the value upon write and store it in the db, sort like any
other field.
or
db.define_table('tabletest', Field('yes', 'integer'), Field('no',
'integer'))
class vf():
def tot(self):
return self.tabletest.yes-self.tabletest.no
db.tabletest.virtualfields.append(vf)
will create a virtual field that is computed on read. to sort by the
virtual field you can:
db(db.tabletest.id>0).select().sort(lambda r: r.tot)
hope that helps. (i did not test my code, just typed quickly, beware of
typos)
cfh