Improve sorting of collection numbers to be more numeric like, as Human's would expect #2601
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Collector numbers are not numbers but strings (an unexpectedly large set of non-numbers) and thus the current sort will sort something like "38" before "4"
Solution
Padding the collector numbers with 0 on the left to normalize them is the main improvement. Other tricks based on the sorts of collector number formats include:
I also tried using a natural sorting library like https://www.npmjs.com/package/natural-orderby but that resulted in some unexpected orders from what I'd expect such as:
In comparison the sort I implemented gives for those cases:
Also the library uses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare which has some mobile browser incompatibility with respect to locale which the library does use.
Testing
Tested the sorts with both "Group by Set then Collector number" and "Sort just by Collector number"
Before
Sorting of collector numbers within a set:



Sorting of collector numbers without set grouping:
Sorting of collector numbers with The List cards:
After
Sorting of collector numbers within a set:

Sorting of collector numbers without set grouping:

Sorting of collector numbers with The List cards:

Cases this doesn't handle
World championship decks, since those are in format of

<competitor initials>-<number>[sb]
Unknown event cards, since those start with characters then numbers but have different total lengths
