Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AC8EF632210 for ; Mon, 19 Oct 2009 14:33:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80702-01 for ; Mon, 19 Oct 2009 17:32:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1829E62F1B2 for ; Mon, 19 Oct 2009 14:32:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n9JHWoH6008018; Mon, 19 Oct 2009 13:32:50 -0400 (EDT) To: "Oliveiros C," cc: "Adrian Klaver" , pgsql-sql@postgresql.org Subject: Re: How to order varchar data by word In-reply-to: References: <6caee9520910140240u13daba93ua20637642727776e@mail.gmail.com> <99F66F53142145DE8127EAF7423AF726@marktestcr.marktest.pt> <200910141354.17785.aklaver@comcast.net> Comments: In-reply-to "Oliveiros C," message dated "Mon, 19 Oct 2009 18:07:57 +0100" Date: Mon, 19 Oct 2009 13:32:49 -0400 Message-ID: <8017.1255973569@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.11 tagged_above=-10 required=5 tests=BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 200910/71 X-Sequence-Number: 33270 "Oliveiros C," writes: > If any one can explain me exactly how the order by clause works on varchars, > I 'd really appreciate it. It sorts according to the sort order imposed by your locale setting (see LC_COLLATE in particular). A lot of locales have weird and wonderful rules that embody somebody's notion of "dictionary order". If you don't like it, try switching to C locale. Or you could learn enough about locale definitions to create your own. regards, tom lane