Re: [personal kdb+] Rearrange the expression variable

http://nsl.com/papers/order.htm

order:{?|,/(?,/x@)\y}

/ d:c+b
/ c:-b
/ e:d*a
/ b:10
/ a:20

s.d:cb
s.c:,b s.e:da s.b:0#
s.a:0#`

order[s;!s]

Nice problem - thanks Stevan for the solution.

Here’s a q port:

s:poqnm!(on;n;pm;;)

order: {distinct reverse raze (raze x@) scan key x}

order[s]