HubDB - Sort by sometimes unfilled parameter



I'm trying to create a component that will display a list of items from a HubDB database and want to work out how to cover up for the times when people forget to fill in that field.

The field in question is priority and if priority is left unfilled I want it to default to -999999… or as close to negative infinity as possible.

Is this possible using map, or can sort auto send unfilled items to the end of the array?
At the moment I'm getting a java.lang.NullPointerException


  • Brook


I very quickly found out this can be achieved in multiple steps using selectattr and rejectattr.
Is there a simpler way of doing this?

If not, I think I can survive with this for now.

{% set rows_table=hubdb_table_rows(123456) %}
{% set sorted_rows=integrations_raw|rejectattr('priority', 'none')|sort(True, False, 'priority') %}
{% set unsorted_rows=integrations_raw|selectattr('priority', 'none') %}
{% set sorted_table=sorted_integrations + unsorted_integrations %}


Hi @brookjordan,

That's how I would have done it; if any other community members have ideas, I'd love to hear them! Otherwise, feel free to mark your post as the solution so future community members can benefit from your solution.