See https://stackoverflow.com/questions/9173558/postgresql-order-by-issue-natural-sort
or https://pgxn.org/dist/pg_natural_sort_order/
Basically, we need the following:
P1, P4, P3, P1a, P4a, P1b
to be sorted as follows:
P1, P1a, P1b, P3, P4, P4a,
Currently it sorts like this:
P1, P3, P4, P1a, P1b, P4a
See https://stackoverflow.com/questions/9173558/postgresql-order-by-issue-natural-sort
or https://pgxn.org/dist/pg_natural_sort_order/
Basically, we need the following:
P1, P4, P3, P1a, P4a, P1b
to be sorted as follows:
P1, P1a, P1b, P3, P4, P4a,
Currently it sorts like this:
P1, P3, P4, P1a, P1b, P4a