Ming sort command

11 views
Skip to first unread message

Ferdinand Holzner

unread,
Oct 17, 2016, 4:21:12 PM10/17/16
to TurboGears
Hi,

i'm trying to figure out how to implement sorting into the DataGrid using MongoDB with ming.

Basically i took the example in the DataGrid documentation and tried to change it for Ming.

ordering = kw.get('ordercol')

if ordering and ordering[0] == '+':
    places
= places.sort(ordering[1:], ming.DESCENDING) # Descending

elif ordering and ordering[0] == '-':
    places
= places.sort(ordering[1:], ming.ASCENDING) # Ascending

But for some reason it doesn't work. It crashes with the following error message:

TypeError: must use keyword argument for key function


I also tried to enter the keyword instead of "ordering[1:]", but i get the same error. Any idea what's wrong?

Alessandro Molina

unread,
Oct 17, 2016, 4:24:10 PM10/17/16
to TurboGears
As you can sort by multiple fields, it should be .sort([(fieldname, order)]) you miss a [ ]

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+unsubscribe@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Ferdinand Holzner

unread,
Oct 20, 2016, 5:12:03 PM10/20/16
to TurboGears
Not sure why i don't get a e-mail if someone posts, although i've set it so...

Thanks, got it working now.


Am Montag, 17. Oktober 2016 22:24:10 UTC+2 schrieb Alessandro Molina:
As you can sort by multiple fields, it should be .sort([(fieldname, order)]) you miss a [ ]
On Mon, Oct 17, 2016 at 6:32 PM, Ferdinand Holzner <ferdinan...@gmail.com> wrote:
Hi,

i'm trying to figure out how to implement sorting into the DataGrid using MongoDB with ming.

Basically i took the example in the DataGrid documentation and tried to change it for Ming.

ordering = kw.get('ordercol')

if ordering and ordering[0] == '+':
    places
= places.sort(ordering[1:], ming.DESCENDING) # Descending

elif ordering and ordering[0] == '-':
    places
= places.sort(ordering[1:], ming.ASCENDING) # Ascending

But for some reason it doesn't work. It crashes with the following error message:

TypeError: must use keyword argument for key function


I also tried to enter the keyword instead of "ordering[1:]", but i get the same error. Any idea what's wrong?

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages