Skip to content

Improve documentation of sort #27661

Closed
@bkamins

Description

@bkamins

Following issue #26741 I have another problem with sort when using order argument. Consider the following inconsistency as an example (similar thing is present with lt):

julia> sort([1,-1,2], by=identity, order=Base.By(abs))
3-element Array{Int64,1}:
  1
 -1
  2

julia> sort([1,-1,2], by=x->-x, order=Base.By(abs))
3-element Array{Int64,1}:
  2
  1
 -1

In the first case, following the implementation in ordering.jl, Julia ignores by argument in the first case, because it is equal to the default and in the second case it respects it.

In general order argument is not documented well and it defaults to a non-exported value.
I am not sure, given we are in 0.7.0-alpha stage if this should be:

  • fixed (e.g. by not exposing order argument in public API)
    or
  • only documented precisely describing the way it works (or at least saying to either use lt, by and rev or order keyword argument)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentationgood first issueIndicates a good issue for first-time contributors to JuliasortingPut things in order

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions