Hi Andriy,
orderby maps into a database dependent order-by function, so I would say it
is not possible to use orderby for that purpose.
But as Niphlod points out you can use the sort function of the Rows object
and accomplish your objective in two steps:
rows = db().select(db.person.ALL)
sorted = rows.sort(lambda row: row.name.split()[-1])
Denes
On Tuesday, January 1, 2013 7:54:29 AM UTC-5, Andriy wrote:
>
> I have a table with 'name' Field:
> db.define_table('person', Field('name', 'string'))
>
> 'name' is in format 'Name Lastname', ie, "Mark Twain". Can I sort such
> records by Lastname when selecting with "orderby"? Like this:
> db(db.person).select(db.person.name, orderby=?)
>
> I thought about writing lambda with db.person.name.split(' ', [-1]) but
> can not figure it out...
>
--