Skip to content

sort: Float64Slice.Less does not treat -0 as less than +0 #33440

Open
@dsnet

Description

@dsnet

Using Go1.12

Consider this snippet:

fs := []float64{math.Copysign(0, +1), math.Copysign(0, -1)}
sort.Stable(sort.Float64Slice(fs))
fmt.Println(fs)

This currently prints:

[0 -0]

I expected this to print:

[-0 0]

Either this case be documented or we fix the Float64Slice.Less method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions