Sort data in Browser: Table Sorter and JCI-Plugin

  • Your task:
    Display JSON-data in the browser in a table which is sortable by the user.
  • Solution:
    Install JCI-Plugin and the plugin “Table Sorter
  • Example-Code:
    [jsoncontentimporterpro url=https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json method=rawget parser=twig] {{description}} <table id=”myTable” class=”tablesorter”>
    <thead><tr>
    <th>no (sortable)</th>
    <th class=”sortless”>x</th>
    <th>x (sortable)</th>
    <th>y (sortable)</th>
    <th>randomno (sortable) </tr></thead>
    <tbody>
    {%for v in values %}
    {% if loop.index<10 %}
    <tr><td>{{loop.index}}</td><td>{{v.x}}</td><td>{{v.x}}</td><td>{{v.y}}</td><td>
    {{ random(5000) }} </td></tr>
    {% endif %}
    {% endfor %}
    </tbody></table>
    [/jsoncontentimporterpro]
In action:
The number of Bitcoin transactions added to the mempool per second.
no (sortable) x x (sortable) y (sortable) randomno (sortable)
1151345092015134509204.345763888894324
2151345290015134529004.388958333333061
3151345488015134548804.549479166671350
4151345686015134568604.583263888893866
5151345884015134588404.661006944444272
6151346082015134608204.725972222221443
7151346280015134628004.696527777782659
8151346478015134647804.818194444444913
9151346676015134667604.80944444444857

Credits: Thank you Lawrence from South Melbourne, Australia