Continuing the discussion from Display a JSON Array:
At this moment there is no special functionality to sort arrays. However, it should not be difficult to develop, I'll try to come up with something in the next few days and announce when it is released.
There are currently 2 ways of sorting arrays:
Sort arrays - approach # 1
This function is native to Twig.
asort PHP function.
However, not exactly what you need for your case.
Sort arrays - approach # 2
This WILL work for your case!
You can use a table plugin. One of the most popular plugins is DataTable.
You'll have to load the plugin in your
<head> of the page, or in the end of the page's body, just before the
</body> tag. This can be easily done either in your WordPress theme, where you can specify additional JS files to be loaded, or using a special WordPress plugin that allows to add JS scripts and CSS files to page header / footer.
Once the DataTable is loaded, you can use attributes right into your Twig template to specify which column to order the table by. See this page, section titled "HTML 5 data attributes".
Using a plugin has many benefits. For instance, you will have the table sortable by a user in real time - by clicking on the column headers.
Please let me know if option #2 works for you.