How to Sort darktable.gui.selection

I take my image table from darktable.gui.selection (darktable lua documentation - darktable.gui.selection) but that is not sorted as I view on the screen after selected “sort by” (id, rating, time, etc…).
How to charge image table as sorted as on the screen?

Thanks.

Use darktable.gui.action_images