Filtering row from data tables and ordering them

What I’m trying to do:

I would like to get a group of rows from the data table that match the users selected ‘project’ (my data table has a project column that I am using to filter the search results)

What I would like to do is sort the rows with another column so that the rows are in order.

What I’ve tried and what’s not working:

For filtering:

df = app_tables.my_datatable.search(Project= project)

Which is returning a <LiveObject: anvil.tables.SearchIterator>

I was thinking it would return a list of dictionaries that I use to sort (based on the docs)

For sorting, I have tried:

df_ordered = sorted(df, key= lambda c: c['row'])

I am aware of the order_by() function but don’t know how to combine it with search().

You can use this to return list of dics:

1 Like

Thank you so much Tony, that solved it.

The order_by has to be before the keyword parameters for search, e.g.:

df = app_tables.my_datatable.search(tables.order_by('row'), Project= project)
2 Likes

Hey Jay,

I was hoping there was a one liner to do what I was looking for, I just didn’t know how to structure it and ended up looking other methods.

my first attempt was:

df = app_tables.my_datatable.search(Project= project).tables.order_by('row')

which didn’t work…

Thank you for clarifying that.