Q: How to sort arrays in PostgreSQL?

A: `select array(select unnest(x) order by 1)`

where `x` is a column of array type.

That's the neatest implementation that I was able to find.

I was hoping for optimized `array_sort()` but it doesn't seem to exist.

Interestingly, I couldn't find any mention of `array()` in Postgres docs.

#postgres #sql

Reply to this note

Please Login to reply.

Discussion

No replies yet.