News for hackers. Stuff that matters.
Re:When I say "alphabetical order", I mean "alphabetical order" by dcomp on Sunday September 28, 2025 @12:18PM (#45405531)
I think the algorithm is probably incorrect. A number starting with 0 should be treated lexically not numerically. Otherwise you have a situation where img_1_01.jpg and img_01_1.jpg does not have a complete ordering.
Re:When I say "alphabetical order", I mean "alphabetical order" by crazygringo on Sunday September 28, 2025 @01:19PM (#45406071)
That's not the issue.

The issue here is that one camera appends milliseconds to the seconds without a separator, and the other uses a separator.

So of course the ones that include milliseconds look like bigger numbers and get sorted last.

Leading zeros aren't the issue here.

Re:When I say "alphabetical order", I mean "alphabetical order" by re on Sunday September 28, 2025 @12:53PM (#45405868)
> Otherwise you have a situation where img_1_01.jpg and img_01_1.jpg does not have a complete ordering.

(Good) "natural sort" implementations generally have ways of handling ties like this. It's similar to the problem of case-insensitive sort over case sensitive sets.

Re:When I say "alphabetical order", I mean "alphabetical order" by gregates on Sunday September 28, 2025 @12:22PM (#45405565)
It wouldn't be the first time widely-used software sorted numbers by a function that does not produce a total ordering. For example, Excel: https://gregat.es/excel-numeric-order-transitivity/