CASE: order a drop or custom collection on certain object

Take this overview of done investments, where I’ve put in all investments but not in the order of the data they were done:

This is the code behind it:

{% stripnewlines %}
{% fori acc in custom.investments_office_material %}
  {% if forloop.first %}
| Date
| Description
| Value
{% newline %}
|----15%----
|----60%----
|----------:+
  {% endif %}
{% newline %}  
| {% input acc.date as:date %}
| {% input acc.descr as:text size:mini placeholder:"Description" %}
| {% input acc.value as:currency %}
{% endfori %}
{% endstripnewlines %}

There’s a way to order your custom collection on that field date, by using the addnewinputs tag in combination with an sort filter on that custom collection.

This is done by this code:

{% addnewinputs %}
  {% assign investments = custom.investments_office_material | sort:"date" %}
{% endaddnewinputs %} 

So first you’ll need to assign your collection to a variable (investments in my case), and filter it by sort on an objects (name of the object is date and not custom.date !).
This needs to be done in the addnewinputs-tag as well, so it automatically will order your fori-loop as soon as you’ve entered a new input.
Of course, in the fori-loop you’ll need to address the variable you just created and not the original custom collection:

{% addnewinputs %}
  {% assign investments = custom.investments_office_material | sort:"date" %}
{% endaddnewinputs %}


{% stripnewlines %}
{% fori acc in investments %}
  {% if forloop.first %}
| Date
| Description
| Value
{% newline %}
|----15%----
|----60%----
|----------:+
  {% endif %}
{% newline %}  
| {% input acc.date as:date %}
| {% input acc.descr as:text size:mini placeholder:"Description" %}
| {% input acc.value as:currency %}
{% endfori %}
{% endstripnewlines %} 

Output: