Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I just tried it on Mac, its sorted in the order you listed. Extending it a bit, the order is:

photo1 photo01 photo001 photo0001 photo2

So the shorter representation of the same number comes first. It does make intuitive sense to me.



But did it show as a list or an ordered collection of folders? And the second time you opened the folder did it rearrange into a haphazard scattering with items off the edge of the window?


> I just tried it on Mac, its sorted in the order you listed. Extending it a bit, the order is:

> photo1 photo01 photo001 photo0001 photo2

What you enumerated is known as "ascending lexicographical ordering" and has nothing to do with "the shorter representation of the same number", but instead the ASCII[0] character values in each file name.

0 - https://man.freebsd.org/cgi/man.cgi?query=ascii&apropos=0&se...


With ASCII lexicographic ordering, photo01 would come before photo1.


> With ASCII lexicographic ordering, photo01 would come before photo1.

Good catch. I did not closely inspect the ordering initially presented, which was:

  photo1 photo01 photo001 photo0001 photo2
This does not represent a valid sort order based solely on file names produced by `ls`, which would be:

  photo0001 photo001 photo01 photo1 photo2




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: