Introduce a SQL-callable function array_sort(anyarray).
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Apr 2025 22:03:55 +0000 (18:03 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Apr 2025 22:03:55 +0000 (18:03 -0400)
commit6c12ae09f5a5d6c153eaea7901542591dc28fb9e
tree49e351e00c0f30aa00bac57a2dbbaedd9329ebfa
parent6da2ba1d8a031984eb016fed6741bb2ac945f19d
Introduce a SQL-callable function array_sort(anyarray).

Create a function that will sort the elements of an array
according to the element type's sort order.  If the array
has more than one dimension, the sub-arrays of the first
dimension are sorted per normal array-comparison rules,
leaving their contents alone.

In support of this, add pg_type.typarray to the set of fields
cached by the typcache.

Author: Junwang Zhao <zhjwpku@gmail.com>
Co-authored-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CAEG8a3J41a4dpw_-F94fF-JPRXYxw-GfsgoGotKcjs9LVfEEvw@mail.gmail.com
doc/src/sgml/func.sgml
src/backend/utils/adt/array_userfuncs.c
src/backend/utils/cache/typcache.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/utils/typcache.h
src/test/regress/expected/arrays.out
src/test/regress/expected/collate.icu.utf8.out
src/test/regress/sql/arrays.sql
src/test/regress/sql/collate.icu.utf8.sql
src/tools/pgindent/typedefs.list