sort_natural does no natural sort
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
sort_natural is able to sort case-insensitively but does not sort numbers in the expected way.
The sort would e.g. return
10,11,2,3,4instead of the expected2,3,4,10,11z11,z2instead of the expectedz2,z11
The overall definition of "natural" sort seems to be "how a human would sort the list", so it is a little vague. But the consensus seems to be that natural sorting should sort by numbers, not by characters:
- https://en.wikipedia.org/wiki/Natural_sort_order
- https://www.php.net/manual/en/function.natsort.php
- https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
- https://www.tutorialspoint.com/natural-sort-in-javascript
- https://stackoverflow.com/q/4836710
The fallout is, e.g. that navigation lists sorted by liquid are in the wrong order. This is done in multiple Jekyll themes, for example
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the sort_natural implementation and any tests covering its ordering behavior. Verify the current results against the examples in the issue, then update the behavior so numeric portions sort by value, including values such as 10, 11, 2 and z11, z2; done means these cases produce the expected natural order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100