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 1msaKE-0007Gu-At for pgsql-admin@arkaria.postgresql.org; Thu, 02 Dec 2021 00:51:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msaKD-0002hp-26 for pgsql-admin@arkaria.postgresql.org; Thu, 02 Dec 2021 00:51:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msaKC-0002hD-CP for pgsql-admin@lists.postgresql.org; Thu, 02 Dec 2021 00:51:48 +0000 Received: from quail.birch.relay.mailchannels.net ([23.83.209.151]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msaK9-0007ED-Du for pgsql-admin@lists.postgresql.org; Thu, 02 Dec 2021 00:51:47 +0000 X-Sender-Id: hostpapa|x-authuser|list.pg.gavan@pendari.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id DD73DE19AF; Thu, 2 Dec 2021 00:51:42 +0000 (UTC) Received: from hp309.hostpapa.com (unknown [127.0.0.6]) (Authenticated sender: hostpapa) by relay.mailchannels.net (Postfix) with ESMTPA id E52FEE194D; Thu, 2 Dec 2021 00:51:41 +0000 (UTC) X-Sender-Id: hostpapa|x-authuser|list.pg.gavan@pendari.org Received: from hp309.hostpapa.com (hp309.hostpapa.com [69.90.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.112.64.119 (trex/6.4.3); Thu, 02 Dec 2021 00:51:42 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: hostpapa|x-authuser|list.pg.gavan@pendari.org X-MailChannels-Auth-Id: hostpapa X-Coil-Abiding: 7ff23c8867a73e0f_1638406302665_54351688 X-MC-Loop-Signature: 1638406302665:349528724 X-MC-Ingress-Time: 1638406302665 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pendari.org ; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References :In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=axGSONtqzvVhMxNSjzUxs2vShYMNy0I9M0yCVoOGseE=; b=rRcTZuyCwnxFmJzrTBi1MAzomZ xdSRNg0IGm+eZ4+wqGyFPs2j1Ry0NOxzEvAyutQO9HudCj0PtE2X/0fqlCtTh2OdyR976O4rmLbJD gELJtTCq9fkYncTFM7BrJpF3o+Uad1zuRqRGqvTRTKYMYlhbtN+foqjxejLWMmY0jUU+TwshujuSK ObhdqzkisHwBrgLHgWFUr93W1h6ePfLgMpNlY31X3NmPhXZsQ9Tja70HWiIPpxmUYFx0dg0b4K/QA IFlyHSZAmlmO1OQvj5IuGbbdiZOHRPmbeAsunGWUsjaPLz/7aybDL125+u8HZL+VhsP0by66V8XLd Ovr28D8A==; Received: from [103.152.126.81] (port=47687 helo=[169.254.33.153]) by hp309.hostpapa.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1msaK5-003Woj-01; Thu, 02 Dec 2021 11:51:40 +1100 From: Gavan Schneider To: Pgsql-admin Cc: Sbob , "David G. Johnston" Subject: Re: sort output per alpha-numeric? Date: Thu, 02 Dec 2021 11:51:35 +1100 X-Mailer: MailMate (1.14r5850) Message-ID: <1BB3B402-0456-4685-B633-86ECA5328892@pendari.org> In-Reply-To: References: <6b1034cc-d98d-f3a7-6dd9-264bb0f934d8@quadratum-braccas.com> <3ADA4F64-1223-44EF-97E1-0BCA1D9A643F@pendari.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-AuthUser: list.pg.gavan@pendari.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2 Dec 2021, at 10: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 11x= 14, >> etc) >> >> Is there an easy way to do this? >> >> You can sort by an expression. For the data as shown the following sho= uld >> >> 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-di= git > scenarios before making a final choice (if there are any besides "8" to= > worry about). > This piqued my interest and confirmed several sizes in the single digit (= inch) category are considered standard: https://pikwizard.com/blog/standa= rd-photo-sizes/ This isn=E2=80=99t too big a deal provided the sizes end up in the order = the OP wants so the more elegant substituting of =E2=80=98x=E2=80=99 wil= l generate the correct order as far as I can tell from superficial inspec= tion. In my own (more pedestrian) way I would have these sizes as their own tab= le with ranking as a column (i.e., calculate once and store), and use tha= t table to enforce a foreign key constraint to prevent any rogue sizes ge= tting into the customer relevant tables. Then the ranking number is total= ly arbitrary. Of course good practice is to allow 10, or more, between nu= mbers because there is always that something which comes along later. Th= e job is small enough that is can be done quicker by hand. Gavan Schneider =E2=80=94=E2=80=94 Gavan Schneider, Sodwalls, NSW, Australia Explanations exist; they have existed for all time; there is always a wel= l-known solution to every human problem =E2=80=94 neat, plausible, and wr= ong. =E2=80=94 H. L. Mencken, 1920