in reply to Dynamic sort criteria for an Array in Perl
my $sub = eval "sub { $buildString }"; my @sorted = sort $sub @unsorted; [download]
Be very careful, though; don't let the user run arbitrary code. Also note that debugging such code is hard.