Update natural sort for lists #11
No reviewers
Labels
No labels
Compat
Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: auxolotl/lib#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "aleksi/lib:natural-sort"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This commit updates the natural sort for lists to give special
consideration to numbers. Previously, the invocation of
lib.strings.split did not match anything, because the intended regex was
actually escaped by lib.strings.split. Hence we use builtins.split
instead.
Also, the lib.strings.into.int only would consider the first
character of the string and turn it into a char code. This commit
implements another function to parse a string of decimal digits into
an int.
@ -20,0 +20,4 @@## Convert from an ASCII representation of an integer to said integer.#### @type String -> IntegerparseInt =I'm not sure I've chosen the best possible name for this function. I had a hard time coming up with something else.
it's a perfectly good name :)
I think the pattern in lib would have this named:
lib.strings.from.int@ -33,0 +41,4 @@cmpVectors =a: b:if a.isNumber && !b.isNumber then# Numbers come even before special characters in this sorting.Might be unnatural?
I would put numbers at the same place in the collation that digit characters come in ASCII.... after '/' and before ':'. I realize that's awkward because it's halfway through the punctuation, but that way it will agree with what directory listings do, and a lot people name their files based on how
lsand similar tools collate things.@ -33,0 +47,4 @@1else# lib.numbers.compare happens to be compatible with both strings# and integers.This compatibility might be unintentional.
881275d80dtob620f6581cWIP: Update natural sort for liststo Update natural sort for listsgood idea and well implemented; I did leave a suggestion about the semantics above, which imo we should discuss and agree on before merging.
is this code actually used right now? by what? I'd like to be clearer about which listings it would immediately effect, if we were to merge it
@ -39,3 +50,3 @@value]) list;isLess = a: b: (lib.lists.compare lib.numbers.compare (builtins.head a) (builtins.head b)) < 0;cmpVectors =It is a small thing, but can we write out
compareinstead ofcmp?oh, yes, seconded, good call
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.