uses GroupBy to partition trimmed elements of an array using a custom comparer