in reply to Sorting Arrays Without using SORT function

Two solutions:

use Algorithm::Loops qw( NextPermute ); sub mysort { my @a = @_; 1 while NextPermute(@a); return @a; } my @unsorted = qw( a c b d ); my @sorted = mysort(@unsorted); print("@sorted\n");
use IPC::Run3 qw( run3 ); sub mysort { my @unsorted = map "$_\n", @_; run3([ 'sort' ], [ map "$_\n", @unsorted ], \my @sorted); chomp(@sorted); return @sorted; } my @unsorted = qw( a c b d ); my @sorted = mysort(@unsorted); print("@sorted\n");