This repository has been archived on 2022-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
patterns/templatemethod/sort/app.d

32 lines
514 B
D

import std.stdio : writeln;
import std.algorithm : sort;
import duck;
void main()
{
Duck[] ducks = [
new Duck("Daffy", 8),
new Duck("Dewey", 2),
new Duck("Howard", 7),
new Duck("Louie", 2),
new Duck("Donald", 10),
new Duck("Huey", 2)
];
writeln("Before sorting:");
display(ducks);
ducks.sort();
writeln("\nAfter sorting:");
display(ducks);
}
void display(Duck[] ducks)
{
foreach (val; ducks)
{
writeln(val);
}
}