Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msepP-0002Uu-TW for pgsql-admin@arkaria.postgresql.org; Thu, 02 Dec 2021 05:40:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msepN-00051m-Ui for pgsql-admin@arkaria.postgresql.org; Thu, 02 Dec 2021 05:40:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msepN-00051A-G9 for pgsql-admin@lists.postgresql.org; Thu, 02 Dec 2021 05:40:17 +0000 Received: from forward501p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:120]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msepI-0007hp-Qb for pgsql-admin@lists.postgresql.org; Thu, 02 Dec 2021 05:40:16 +0000 Received: from vla1-16aa0380438a.qloud-c.yandex.net (vla1-16aa0380438a.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:d87:0:640:16aa:380]) by forward501p.mail.yandex.net (Yandex) with ESMTP id 578016212F86; Thu, 2 Dec 2021 08:40:10 +0300 (MSK) Received: from vla5-445dc1c4c112.qloud-c.yandex.net (vla5-445dc1c4c112.qloud-c.yandex.net [2a02:6b8:c18:3609:0:640:445d:c1c4]) by vla1-16aa0380438a.qloud-c.yandex.net (mxback/Yandex) with ESMTP id ljzjsHF4Oe-e9dWrINl; Thu, 02 Dec 2021 08:40:10 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1638423610; bh=DB+cZkUeO7uMaZNPhTmAUPXL29Ex02M1beuJooK8754=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID:Cc; b=H2sBQaFqj4ALytRFa0MrvnYqXMN5hB3+d3jihGMHB11k9IzsNJ+Q4b1TXzag0sWqm O0c9fyswwK+NZTfJ/L3JPRLfgYLGSAqgza2Dt2AfYwCLqhH+JowGgZHWUdsmN5uNfK QXsqtvx6UNR8JRX+M/zK1X594d0dpb37ZXeId9ho= Authentication-Results: vla1-16aa0380438a.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by vla5-445dc1c4c112.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id jHPmbpeQb4-e9RGhQ5P; Thu, 02 Dec 2021 08:40:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Fwd: 2 Subject: Re: sort output per alpha-numeric? To: "David G. Johnston" , Gavan Schneider Cc: Pgsql-admin , Sbob References: <6b1034cc-d98d-f3a7-6dd9-264bb0f934d8@quadratum-braccas.com> <3ADA4F64-1223-44EF-97E1-0BCA1D9A643F@pendari.org> From: Alexey M Boltenkov Message-ID: Date: Thu, 2 Dec 2021 08:40:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------C9720F3F6134978563D6049E" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------C9720F3F6134978563D6049E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 12/02/21 02:55, David G. Johnston wrote: > On Wed, Dec 1, 2021 at 4:35 PM Gavan Schneider > > wrote: > > On 2 Dec 2021, at 9:50, David G. Johnston wrote: > > On Wed, Dec 1, 2021 at 3:38 PM Sbob > > wrote: > > I want the displayed print\_size to be ordered by size > (8x10, then 11x14, etc) > > Is there an easy way to do this? > > You can sort by an expression. For the data as shown the > following should > > > A little more heavy handed might be to convert the two numbers > into a single integer for ranking, e.g., > > Good idea, but "replace(print_size, 'x', '0')::integer" seems like a > simpler implementation - though I'd want to double-check some > single-digit scenarios before making a final choice (if there are any > besides "8" to worry about). > > David J. > Natural sort may be less invasive. order by length(print_size), print_size --------------C9720F3F6134978563D6049E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
On 12/02/21 02:55, David G. Johnston wrote:
On Wed, Dec 1, 2021 at 4:35 PM Gavan Schneider <list.pg.gavan@pendari.org> wrote:

On 2 Dec 2021, at 9:50, David G. Johnston wrote:

On Wed, Dec 1, 2021 at 3:38 PM Sbob <sbob@quadratum-braccas.com> wrote:

I want the displayed print\_size to be ordered by size (8x10, then 11x14, etc)

Is there an easy way to do this?

You can sort by an expression. For the data as shown the following should


A little more heavy handed might be to convert the two numbers into a single integer for ranking, e.g.,

Good idea, but "replace(print_size, 'x', '0')::integer" seems like a simpler implementation - though I'd want to double-check some single-digit scenarios before making a final choice (if there are any besides "8" to worry about).

David J.

Natural sort may be less invasive.

order by length(print_size), print_size


--------------C9720F3F6134978563D6049E--