-
Notifications
You must be signed in to change notification settings - Fork 18k
sort: document the ordering requirements of Less #34915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @jowu - could you please explain what you mean by "total order" ? Thanks. |
Sure. In short, the function has to meet these criteria: https://en.wikipedia.org/wiki/Total_order |
The
|
I think the correct term is strict partial order. |
That being said, the incomparability of So if A specific term for this type of strict partial order is a strict weak ordering. |
I don't think that is right. You can have |
Doesn't that imply that there's no way to distinguish between two elements being equal and two elements being incomparable? Additionally, I don't think sort reorders the list |
Indeed, this is strange. I guess it is expected now that I think about it, quicksort won't work if a completely incomparable element is picked as the pivot. So maybe there is something stronger we require.
prints
|
What does it mean to sort a list of values when some of the values are incomparable? What do you expect to happen? |
Yes, that is exactly the equivalence relation we want. We want a totally-ordered partition where
If incomparability is transitive, then I should expect incomparable values to be grouped together. However, if that contract is violated like in Keith's example, then the sort may not be accurate. |
Change https://golang.org/cl/261959 mentions this issue: |
What version of Go are you using (
go version
)?But this should apply to all.
Does this issue reproduce with the latest release?
Yes.
sort doc should remind users that the 'less' function must be a total order.
The text was updated successfully, but these errors were encountered: