perl turbo sort

Hey everyone,
I was trying to do the turbo sort challenge with perl and I am having a hard time splitting it. Here is what I have so far:

my @numbers = <>;
my @sorted = sort {$a <=> $b} @numbers;
split /^/, @sorted;
print @sorted;

Any insight is greatly appreciated! :slight_smile:

hard time splitting it? please mention your problem in detail.
Further please see that the argument passed to split function is a scalar variable which you can split using the pattern specified but in your code you have passed an array to split function.Hope that helps.

As pointed out by @tech_ankur11 , when you already have the sorted array, the numbers are already stored as separate sorted elements. Hence, there’s no point in splitting !
Also the problem that you are attempting requires more optimisation, standard quick sort and merge sort will get time limit exceeded. And the sort function in perl uses those two algorithms only. You can read about it here : So implement your own sort function, counting sort maybe…