Re: sort output per alpha-numeric?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2 Dec 2021, at 10:55, David G. Johnston wrote:

> On Wed, Dec 1, 2021 at 4:35 PM Gavan Schneider <list.pg.gavan@xxxxxxxxxxx>
> wrote:
>
>> On 2 Dec 2021, at 9:50, David G. Johnston wrote:
>>
>> On Wed, Dec 1, 2021 at 3:38 PM Sbob <sbob@xxxxxxxxxxxxxxxxxxxxx> 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).
>
This piqued my interest and confirmed several sizes in the single digit (inch) category are considered standard: https://pikwizard.com/blog/standard-photo-sizes/

This isn’t too big a deal provided the sizes end up in the order the OP wants so the more elegant substituting of  ‘x’ will generate the correct order as far as I can tell from superficial inspection.

In my own (more pedestrian) way I would have these sizes as their own table with ranking as a column (i.e., calculate once and store), and use that table to enforce a foreign key constraint to prevent any rogue sizes getting into the customer relevant tables. Then the ranking number is totally arbitrary. Of course good practice is to allow 10, or more, between numbers because there is always that something which comes along later.  The job is small enough that is can be done quicker by hand.

Gavan Schneider
——
Gavan Schneider, Sodwalls, NSW, Australia
Explanations exist; they have existed for all time; there is always a well-known solution to every human problem — neat, plausible, and wrong.
— H. L. Mencken, 1920






[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux