On Sunday, 1 November 2020 at 09:14:35 UTC, Vino wrote:
[
 Tuple!(string, string)("DEV", "D1"),
 Tuple!(string, string)("DEV", "default"),
 Tuple!(string, string)("DEV", "D1"),
 Tuple!(string, string)("QAS", "Q1"),
 Tuple!(string, string)("QAS", "Q1"),
 Tuple!(string, string)("QAS", "default"),
 Tuple!(string, string)("PRD", "P1"),
 Tuple!(string, string)("PRD", "P1"),
 Tuple!(string, string)("PRD", "default")
]

Required Output
[
 Tuple!(string, string)("DEV", "D1"),
 Tuple!(string, string)("QAS", "Q1"),
 Tuple!(string, string)("PRD", "P1"),
]

From,
Vino.B

I can only test with Phobos (no asdf on run.dlang.io), but isn't just normal sort and uniq what you want?

data[]
    .array
    .sort
    .uniq!((tup1, tup2) => tup1[0] == tup2[0]);

https://run.dlang.io/is/a3KHaE

Sorting "default" values can be tricky but they conveniently cede to explicit D1/Q1/P1 values because of ASCII. Otherwise you would have to provide different sort and uniq predicates.

Reply via email to