std.algorithm.sort fails?

Johannes Pfau spam at example.com
Wed Aug 4 02:17:31 PDT 2010


Hi, I'm trying to sort an array of strings exactly the way it's done in
the docs, but I don't get the expected results:

----------------------------
import std.algorithm;
import std.stdio;
import std.contracts;

void main()
{
    string[] arr = ["unions", "vars", "d_enum", "constructors",
                    "d_alias", "all", "templates", "classes",
                    "interfaces", "sections", "structs", "nested",
                    "functions"];

    sort!("toupper(a) < toupper(b)", SwapStrategy.stable)(arr);

    foreach(string a; arr)
    {
        writeln(a);
    }

    enforce(arr != ["all", "classes", "functions", "constructors",
                             "d_alias", "d_enum", "interfaces", "nested",
                             "sections", "structs", "templates", "unions",
                             "vars"]);
}
-----------------------------

The enforcement fails. Can anyone reproduce this or is this even a known
bug?

-- 
Johannes Pfau


More information about the Digitalmars-d-learn mailing list