storage icon indicating copy to clipboard operation
storage copied to clipboard

Storage list sort order

Open saltcod opened this issue 3 years ago • 1 comments

Sequential numerical filenames don't sort properly.

In Storage, if we have if we have 1.png, 10.png, 11.png, ..., 2.png, 20.png, 21.png, In Finder on Mac, these items would be sorted: 1.png, 2.png, 3.png, ... 10.png, 11.png, etc.

Storage on top, Finder on bottom:

CleanShot 2022-08-24 at 16 16 23@2x

saltcod avatar Aug 24 '22 18:08 saltcod

Shifting this issue to storage-api, the sorting of the files are not on the client side

joshenlim avatar Sep 30 '22 06:09 joshenlim

This is expected, as the ORDER BY clause on a string in Postgres does not take into account the number cardinality, I would recommend sorting by created_at.

Alternatively, if the formatted order is important you can always create an RPC function that will allow you to normalize the string and sort by the numeric value

for example:

SELECT *
FROM   objects
ORDER  BY split_part(name, '.', 1)::numeric;

fenos avatar Sep 30 '22 14:09 fenos