Skip to content

RadixSort broken for By and Perm orders #48

@LilithHafner

Description

@LilithHafner

Sorting with a Perm ordering fails to implement Julia's fallback to compare indices when data are equal (doc, code). Sorting with a By ordering assumes o.order == Forward.

using SortingAlgorithms
using Random: shuffle!
using Base.Order: Perm, By, Forward, Reverse
data = rand(1:10, 10)
inds = shuffle!(collect(1:10))
perm = Perm(Forward, data)
issorted(sort(inds, order=perm), order=perm) # true
issorted(sort(inds, alg=RadixSort, order=perm), order=perm) # false
by = By((-), Reverse)
issorted(sort(inds, order=by), order=by) # true
issorted(sort(inds, alg=RadixSort, order=by), order=by) # false

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