my $out = join "", sort keys %{ { map{ $_ => 1 } split //, $in } };