wrong sort order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

wrong sort order

Alejandro D. Burne
Hi, maybe there is a problem with sorting latin10? Seems to be like
spaces don't exists just sorting.

Version() ->PostgreSQL 8.0.2 on i686-redhat-linux-gnu,
compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)

SELECT nombreasociado, codigoasociado
FROM Asociados
WHERE nombreasociado LIKE 'VILLA%'
ORDER BY 1;

"VILLA CLAUDIA MARIA";2208
"VILLA CLOTILDE";2902
"VILLAFAA'E ALFREDO                 ";916
"VILLAFAA'E MARIA ESTER ROSA        ";933
"VILLAFAA'E MARIA  JULIA            ";7590
"VILLAFANE OSVALDO";3548
"VILLAGGI CARLOS RAUL";1523
"VILLAGRA ILEANA";2305
"VILLAGRA MARIA EUGENIA";7310
"VILLA HORACIO E                    ";2106
"VILLALBA MABEL";397
"VILLALBA ROLANDO A";398
"VILLALBA SILVIA MONICA";2917
"VILLA LUIS SANTIAGO";560
"VILLA MARIA ISABEL";2687
"VILLANI LUCRECIA LILIANA";6657
"VILLANUEVA DIEGO";5888
"VILLANUEVA RICARDO NORBERTO";4608
"VILLA PABLO JOSE";2717
"VILLAR EDUARDO";399
"VILLAR ERNESTO";400
"VILLARES JOSE ANGEL";7174
"VILLAR HUGO EDUARDO";3820
"VILLAR IGNACIO JAVIER";8385
"VILLAR MANUEL ANTONIO";3821
"VILLA ROCA MIGUEL ANGEL";1698
"VILLARREAL NORBERTO";1749
"VILLA SEBASTIAN MARCELO";8159
"VILLA STELLA MARIS";7180
"VILLATA ALBERTO LUIS";7646
"VILLATA MARCELO";5973
"VILLAVICENCIO CARLOS HORACIO";7953

but if you try:

SELECT nombreasociado, codigoasociado
FROM Asociados
WHERE nombreasociado LIKE 'VILLA %'
ORDER BY 1;

"VILLA CLAUDIA MARIA";2208
"VILLA CLOTILDE";2902
"VILLA HORACIO E                    ";2106
"VILLA LUIS SANTIAGO";560
"VILLA MARIA ISABEL";2687
"VILLA PABLO JOSE";2717
"VILLA ROCA MIGUEL ANGEL";1698
"VILLA SEBASTIAN MARCELO";8159
"VILLA STELLA MARIS";7180

 ¿? any clues ¿?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq
Reply | Threaded
Open this post in threaded view
|

Re: wrong sort order

Tom Lane-2
"Alejandro D. Burne" <[hidden email]> writes:
> Hi, maybe there is a problem with sorting latin10? Seems to be like
> spaces don't exists just sorting.

The guys who write the locale specifications think that's a feature,
not a bug ;-)

If you don't want it, either use C locale or create your own locale
definition.  (I have no idea how easy or hard the latter is.)

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Reply | Threaded
Open this post in threaded view
|

Re: wrong sort order

Alejandro D. Burne
Maybe I'm wrong, but this "feature" I don't see it in any other rdbms ;-)

2005/7/2, Tom Lane <[hidden email]>:

> "Alejandro D. Burne" <[hidden email]> writes:
> > Hi, maybe there is a problem with sorting latin10? Seems to be like
> > spaces don't exists just sorting.
>
> The guys who write the locale specifications think that's a feature,
> not a bug ;-)
>
> If you don't want it, either use C locale or create your own locale
> definition.  (I have no idea how easy or hard the latter is.)
>
>                         regards, tom lane
>

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org
Reply | Threaded
Open this post in threaded view
|

Re: wrong sort order

Martijn van Oosterhout
In reply to this post by Alejandro D. Burne
On Sat, Jul 02, 2005 at 11:28:12AM -0300, Alejandro D. Burne wrote:
> Hi, maybe there is a problem with sorting latin10? Seems to be like
> spaces don't exists just sorting.

It's not the encoding, it's the locale. For example, the en_US sorts in
dictionary order (ignore spaces and case).

Hope this helps,
--
Martijn van Oosterhout   <[hidden email]>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

attachment0 (240 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wrong sort order

Alejandro D. Burne
Martjin, this little example show your answer:
$ LANG=es_AR
$ export LANG
$ touch 'villa'
$ touch 'villa f'
$ touch 'villaa'
$ touch 'villat'
$ ls | sort
villa
villaa
villa f
villat

May be this is an off topic, but the question now is how to change or
find a locale that include spaces in sort order.
Thanks!!!, Alejandro.

2005/7/2, Martijn van Oosterhout <[hidden email]>:
> On Sat, Jul 02, 2005 at 11:28:12AM -0300, Alejandro D. Burne wrote:
> > Hi, maybe there is a problem with sorting latin10? Seems to be like
> > spaces don't exists just sorting.
>
> It's not the encoding, it's the locale. For example, the en_US sorts in
> dictionary order (ignore spaces and case).
>
> Hope this helps,
> --

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Reply | Threaded
Open this post in threaded view
|

Re: wrong sort order

Alvaro Herrera
On Mon, Jul 04, 2005 at 12:13:27PM -0300, Alejandro D. Burne wrote:

> May be this is an off topic, but the question now is how to change or
> find a locale that include spaces in sort order.

You can hack the locale definitions from the GNU C library.  Start by
getting the source and reading it -- it's far from a trivial task.

Or you can use the C locale.  But you'll find "strange" behavior with ñ
and accented vowels.

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"Just treat us the way you want to be treated + some extra allowance
 for ignorance."                                    (Michael Brusser)

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org