311
AI Bubblesort (lemmy.world)
you are viewing a single comment's thread
view the rest of the comments
[-] boonhet@sopuli.xyz 5 points 4 days ago

Those are file names, there’s no reason to assume that they would be numerical which is why ls does the right thing.

I’m of the opinion that if you want to store numbers as strings and also sort them, you give them a fixed length and leading zeroes.

[-] balsoft@lemmy.ml 2 points 4 days ago

I agree that it does "the right thing", that is it behaves as documented. But that "right thing" could be surprising to a human.

There's ls -v which does "version sort" which would seem like a more reasonable default, at least for human consumption. I know it's impossible to change now because a bajillion tools all over the place depend on the sort order.

However new tools like eza do this by default:

❯ eza
1  6   11  16  21  26  31  36  41  46  51  56  61  66  71  76  81  86  91  96
2  7   12  17  22  27  32  37  42  47  52  57  62  67  72  77  82  87  92  97
3  8   13  18  23  28  33  38  43  48  53  58  63  68  73  78  83  88  93  98
4  9   14  19  24  29  34  39  44  49  54  59  64  69  74  79  84  89  94  99
5  10  15  20  25  30  35  40  45  50  55  60  65  70  75  80  85  90  95  100
this post was submitted on 30 Sep 2025
311 points (100.0% liked)

Programmer Humor

26715 readers
2090 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS