Better way to sort a JSONB array?

From: Michael Moore <michaeljmoore(at)gmail(dot)com>
To: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Better way to sort a JSONB array?
Date: 2017-08-07 20:13:42
Message-ID: CACpWLjOA2G2eW-x_++gFNG_Cwi4UvzZkUjWGSgsVfjgyVPE9Zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This works, but surely there is a better way to do it:

select jsonb_agg(row_to_json(alias)) from
(Select * from jsonb_populate_recordset(null::tx_portal,
json_table2) order by portal_name) alias
into json_table2;

It sorts the json_table2 array in "portal_name" order.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Midgley 2017-08-07 20:51:37 Re: Better way to sort a JSONB array?
Previous Message Steve Midgley 2017-08-01 15:40:04 Re: PostgreSQL connection with Android Studio