question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unstable sort in case where versions only differ in their build

See original GitHub issue

We’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:closed
  • Created a year ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
rbarroiscommented, May 19, 2022

@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 😃

1reaction
rbarroiscommented, May 26, 2022

Release in v2.10.0 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found