Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How do i sort an numeric array without using sort function. Is ther any way to sort it just with loop in perl??

by Laurent_R (Canon)
on Nov 02, 2017 at 15:05 UTC ( #1202620=note: print w/replies, xml ) Need Help??


in reply to How do i sort an numeric array without using sort function. Is ther any way to sort it just with loop in perl??

You might implement a quick sort algorithm (coded in functional style):
sub qsort { return @_ if @_ < 2; my $pivot = pop; qsort(grep $_ < $pivot, @_), $pivot, qsort(grep $_ >= $pivot, @_); }
Check quick sort on Wikipedia to understand how it works.
  • Comment on Re: How do i sort an numeric array without using sort function. Is ther any way to sort it just with loop in perl??
  • Download Code

Replies are listed 'Best First'.
Re^2: How do i sort an numeric array without using sort function. Is ther any way to sort it just with loop in perl??
by Tabish (Acolyte) on Nov 03, 2017 at 09:20 UTC

    Thank you, i did it

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1202620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2021-06-23 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (114 votes). Check out past polls.

    Notices?