Using std.algorithm how to uniq and sort a multidimensional array?

Gary Willoughby dev at nomad.so
Tue Jan 28 07:06:42 PST 2014


On Tuesday, 28 January 2014 at 14:46:48 UTC, Gary Willoughby 
wrote:
> Using std.algorithm how to uniq and sort a multidimensional 
> array?
>
> e.g. the uniq function takes a function as a predicate but i'm 
> confused how to handle the multiple dimensions.
>
>     string[][] tags;
>
>     tags = tags.uniq!("a[0][1] == b[1][1]").array;
>
> The above is my attempt and it failed.

Gah, it was simpler than i thought, of course.

	tags = tags.sort!("a[1] < b[1]").uniq!("a[1] == b[1]").array;


More information about the Digitalmars-d-learn mailing list