Skip to content

quick_sort returns incorrect results #705

@brson

Description

@brson

std::sort::quick_sort sorts [2, 1, 3] as [1, 3, 2], for both the vec and ivec versions.

fn test_qsort() {
    auto names = ~[mutable 2, 1, 3];

    auto expected = ~[1, 2, 3];

    fn lteq(&int a, &int b) -> bool { int::le(a, b) }
    iqsort(lteq, names);

    auto pairs = ivec::zip(expected, ivec::from_mut(names));
    for (tup(int, int) p in pairs) {
        log_err #fmt("%d %d", p._0, p._1);
        assert p._0 == p._1;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions