Re: order by question

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Steve Clark <sclark(at)netwolves(dot)com>, pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: order by question
Date: 2014-08-07 15:36:28
Message-ID: 1407425788.77494.YahooMailNeo@web122301.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Clark <sclark(at)netwolves(dot)com> wrote:

> I am confused by how postgres 8,4..13 is sorting my data.

> select * from test order by data;
>     data
> ----------
>
>   -
>   --
>   1
>   11
>   11F
>   1F
>   a
>   b
>   C
>   F
>   -F
>   Feneric
>   Generic
> (14 rows)
>
> The first row is a single space, the next row a single -, the next two -- .
> What I don't understand is why the '-F', the ' Feneric' and
> the ' Generic' sort where they do.
>
> I would expect the output to be like this:
>
>     data
> ----------
>
>   Feneric
>   Generic
>   -
>   --
>   -F
>   1
>   11
>   11F
>   1F
>   a
>   b
>   C
>   F
> (14 rows)

>   lc_collate
> -------------
>   en_US.UTF-8

PostgreSQL uses the OS collations.  What you are getting matches my
Ubuntu 14.04 machine:

kgrittn(at)Kevin-Desktop:~/pg/master$ echo $LANG
en_US.UTF-8
kgrittn(at)Kevin-Desktop:~/pg/master$ sort <<XXX
>
>   Feneric
>   Generic
>   -
>   --
>   -F
>   1
>   11
>   11F
>   1F
>   a
>   b
>   C
>   F
> XXX

  -
  --
  1
  11
  11F
  1F
  a
  b
  C
  F
  -F
  Feneric
  Generic

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jungwirth 2014-08-07 15:57:31 Re: Recursive CTE trees + Sorting by votes
Previous Message Adrian Klaver 2014-08-07 15:17:47 Re: Adding 3 hours while inserting data into table