Skip to content

Bug when using Base.By(last) in a BinaryHeap #828

@quiaro21

Description

@quiaro21

I am trying to use the example in the DataStructures documentation. The code is the following:
using DataStructures data = collect(enumerate(["foo", "bar", "baz"])) h2 = BinaryHeap(Base.By(last), data) # Order by 2nd element only first(h2) # => (2, "bar")

I am getting the following error:

ERROR: MethodError: no method matching BinaryHeap(::Base.Order.By{typeof(last), Base.Order.ForwardOrdering}, ::Vector{Tuple{Int64, String}}) Stacktrace: [1] top-level scope @ ~/Desktop/ShortestPath/heaptest.jl:3

Which is weird because I have been using Mutable Binary Heaps for a long time (using also the ordering) and I never had any problem. I have not updated Julia, and I have the latest version of Data Structures. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions