X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 9499A9FA2D5 for ; Tue, 12 Sep 2006 15:26:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 55041-03 for ; Tue, 12 Sep 2006 18:26:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep04.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id B8D609FA1A7 for ; Tue, 12 Sep 2006 15:26:35 -0300 (ADT) Received: from alamut ([85.100.180.34]) by fep04.ttnet.net.tr with ESMTP id <20060912182634.UFDD13992.fep04.ttnet.net.tr@alamut>; Tue, 12 Sep 2006 21:26:34 +0300 Date: Tue, 12 Sep 2006 21:24:39 +0300 From: Volkan YAZICI To: Steven Murdoch Cc: pgsql-sql@postgresql.org Subject: Re: Sorting items in aggregate function Message-ID: <20060912182439.GB1373@alamut> References: <20060912154628.GB4991@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060912154628.GB4991@cl.cam.ac.uk> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.354 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, SPF_PASS X-Spam-Level: *** X-Archive-Number: 200609/83 X-Sequence-Number: 26294 On Sep 12 04:46, Steven Murdoch wrote: > I would like to concatenate sorted strings in an aggregate function. I > found a way to do it without sorting[1], but not with. If the array elements will be made of integers, then you can use sort() procedure comes with intarray contrib module. For instance, SELECT concat(T.sorted_arr) FROM (SELECT sort(arr) FROM tbl) AS T (sorted_arr); If related column will also include text values, you can create a suitable sort() procedure for text[] type and use it instead. Regards.