On 4/3/06, Matthew Peter <survivedsushi@xxxxxxxxx> wrote: > > Hello list. I'm trying to get a unique, sorted varchar array in pl/pgsql. > Essentially a "group by" and "order by"'d varchar[]. > > Anyone got any ideas or point me in the right direction? Thanks. If your data is not an array type coming off the table but you want it to end up that way, check out array_accum at http://www.postgresql.org/docs/8.1/static/xaggr.html. All you have to do is order the data going into the aggregate: select array_accum(d) from ( select d from t order by... ) if your data is starting off as an array type, you have a few options. you might get the most milage out of a pl/perl procedure to sort the type. If the arrays are small and you absolutely had to do it in plpgsql you could copy the values into a temp table, sort it via query, and resinsert into an array using the above technique. merlin