select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / ARRAY FUNCTIONS AND OPERATORS

Sorts the first dimension of the array.

Signatures & examples

array_sort ( array anyarray [, descending boolean [, nulls_first boolean ]] ) → anyarray
Sorts the first dimension of the array. The sort order is determined by the default sort ordering of the array's element type; however, if the element type is collatable, the collation to use can be specified by adding a COLLATE clause to the array argument.
array_sort(ARRAY[[2,4],[2,1],[6,5]]) → {{2,1},{2,4},{6,5}}
Version history 1
  1. PG 17 → 18added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source