Sorting algorithms/Quicksort: Difference between revisions
Content added Content deleted
(Joy) |
(added J solution) |
||
Line 189: | Line 189: | ||
IDL> print,qs([3,17,-5,12,99]) |
IDL> print,qs([3,17,-5,12,99]) |
||
-5 3 12 17 99 |
-5 3 12 17 99 |
||
=={{header|J}}== |
|||
sel=: 1 : 'x # [' |
|||
quicksort=: 3 : 0 |
|||
if. 1 >: #y do. y else. (quicksort y <sel e),(y =sel e),quicksort y >sel e=.y{~?#y end. |
|||
) |
|||
To actually sort data in J, it is more convenient and more efficient to use<tt> /:~ </tt>. |
|||
=={{header|Joy}}== |
=={{header|Joy}}== |