for amusement, here's Raul's code rewritten using /: instead of(<.,>.)/
so now it can sort gnomes as well as numbers..
swap1=: '' 1 : 0
NB. experiment with globals
a=. _2&([\)
b=. /:"1
c=. [: b a
C=: c f.
d=. 2 * [: i. #
e=. +" 0 1
f=. d e ]
F=: f f.
g=. [: , [: f c
G=: g f.
h=. ([,{:)^:(1= 2|#)
j=. [: ({~ g) h
J=: j f.
k=. #{.j
k f.
)
swap2=: {.,sw...@}.
pgs1=: sw...@swap2^:a:
pgs2=: sw...@swap2^:_
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm