unstable sort in case where versions only differ in their build
See original GitHub issueWe’re observing unstable sort in cases where versions only differ in their build.
>>> from semantic_version import Version
>>> v1 = Version("2.0.12+123")
>>> v2 = Version("2.0.12+1")
>>> v3 = Version("2.0.12+321")
>>> v4 = Version("2.0.12+22")
>>> sorted([v1,v2,v3,v4])
[Version('2.0.12+123'), Version('2.0.12+1'), Version('2.0.12+321'), Version('2.0.12+22')]
>>> sorted([v4,v2,v1,v3])
[Version('2.0.12+22'), Version('2.0.12+1'), Version('2.0.12+123'), Version('2.0.12+321')]
>>> sorted([v1,v2,v3,v4])
[Version('2.0.12+123'), Version('2.0.12+1'), Version('2.0.12+321'), Version('2.0.12+22')]
>>>
This is due to Semver mandating that the versions differing only in their build must have the same precedence. Nevertheless, we have an implementation in node which does consider build to yield a stable sorting. Can we have something similar here?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Why is an "unstable sort" considered bad - Stack Overflow
The output order preserves the original input order. An unstable sort, by contrast, there is no guarantee of the order of these two...
Read more >Difference between Stable and Unstable Sorting Algorithm?
A sorting algorithm is said to be stable if it maintains the relative order of numbers/records in the case of tie i.e. if...
Read more >Analysis of different sorting techniques - GeeksforGeeks
Stable/Unstable technique – Out of comparison based techniques, bubble sort, insertion sort and merge sort are stable techniques. Selection ...
Read more >1884-unstable-sort - The Rust RFC Book
Unstable sorting is indistinguishable from stable sorting when sorting primitive integers. It's possible to specialize slice::sort to fall back to slice:: ...
Read more >What is the difference between a stable and unstable sort?
A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in the sorted output...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pombredanne After giving this some more thought, I think that using the same ordering rules as for components of the “prerelease” bits (i.e according to the rules in section 11.4 of Semver) will be the least-surprising way to go.
I’ll have to add some mentions on that topic in the docs, though 😃
Release in v2.10.0 😃