docassemble
docassemble copied to clipboard
DADict.true_values() sorts results in different order than initial order
Given the following interview (where fruits are sorted not alphabetically, but by juiciness)
question: |
Please tell me what you think.
fields:
- "Select the fruits you like": likes_fruit
datatype: checkboxes
choices:
- Pears
- Apples
- Peaches
- Plums
---
mandatory: True
question: |
Summary of your answer
subquestion: |
You like
${ likes_fruit.true_values() }.
If I select pears and apples, the resulting text is "you like apples and pears". I would have expected that the selected values are given in the order that they are specified in the choices list.
If i instead have a subquestion with something like
You like ${DAList(elements=[x for x in likes_fruit if likes_fruit[x]])}
...then values are in the expected order. Maybe true_values()
could have a optional parameter specifying the order of the results?
Sure, in the next version I'll add an optional keyword parameter insertion_order
that you can set to True
if you want the items returned in the underlying dict
's stored insertion order.
I am closing this issue because the insertion_order
feature was implemented.