Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C5BCA632411 for ; Fri, 16 Jul 2010 09:14:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 54405-09 for ; Fri, 16 Jul 2010 12:14:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail2.topex.ro (mail2.topex.ro [82.137.49.134]) by mail.postgresql.org (Postfix) with ESMTP id C04436321FC for ; Fri, 16 Jul 2010 09:14:14 -0300 (ADT) Received: from mail2.topex.ro ([172.27.168.99]) by topex.ro with MailEnable ESMTP; Fri, 16 Jul 2010 15:14:13 +0300 X-ASG-Debug-ID: 1279282450-0717a7e50001-ysJW5H Received: from vr.localnet (89-38-174-194.volio.ro [89.38.174.194]) by mail2.topex.ro with ESMTP id reK4rEJysn2pmerN for ; Fri, 16 Jul 2010 15:14:11 +0300 (EEST) X-Barracuda-Envelope-From: robert.voinea@topex.ro X-Barracuda-AUTH-User: robert.voinea X-ASG-Whitelist: Client From: Robert Voinea To: pgsql-admin@postgresql.org X-ASG-Orig-Subj: Weird sorting order Subject: Weird sorting order Date: Fri, 16 Jul 2010 15:14:09 +0300 User-Agent: KMail/1.13.2 (Linux/2.6.32-24-generic; KDE/4.4.2; i686; ; ) Organization: Topex MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201007161514.09960.robert.voinea@topex.ro> X-Barracuda-Connect: 89-38-174-194.volio.ro[89.38.174.194] X-Barracuda-Start-Time: 1279282450 X-Barracuda-URL: http://172.27.168.99:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at topex.ro X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.56 tagged_above=-10 required=5 tests=BAYES_50=0.8, RCVD_IN_SORBS_WEB=0.77, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: * X-Archive-Number: 201007/103 X-Sequence-Number: 35122 Hi... I have the following table: CREATE TABLE test ( id SERIAL PRIMARY KEY, val VARCHAR(32) NOT NULL ); INSERT INTO test VALUES (DEFAULT, '##34''), (DEFAULT, '##32'), (DEFAULT, '##31'), (DEFAULT, '2ff'), (DEFAULT, '##26'), (DEFAULT, '2##33'), (DEFAULT, '2##25'), (DEFAULT, '2##24'), (DEFAULT, '2##23'), (DEFAULT, '211'), (DEFAULT, '210'), (DEFAULT, '203'), (DEFAULT, '202'), (DEFAULT, '201'), (DEFAULT, '200'); Why is it that when running the query: SELECT * FROM test ORDER BY val; I get the following result? id | val ----+------- 1 | 200 2 | 201 3 | 202 4 | 203 5 | 210 6 | 211 7 | 2##23 8 | 2##24 9 | 2##25 10 | 2##33 11 | ##26 12 | 2ff 13 | ##31 14 | ##32 15 | ##34 (15 rows) Shouldn't value '2ff' be placed right after '211' but before '2##23'? Tested on PostgreSQL 8.2, 8.4, Linux SuSE & Kubuntu. Thank you!... -- Robert Voinea Software Developer Phone: +40 21 408 38 00 / ext. 343 Fax: +40 21 408 38 08 Local time: GMT+2 http://www.topex.ro