cancel
Showing results for 
Search instead for 
Did you mean: 

Re: [personal kdb+] Rearrange the expression variable

sa1
New Contributor

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

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

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

order[s;!s]

1 REPLY 1

jwbuitenhuis
New Contributor
Nice problem - thanks Stevan for the solution.

Here's a q port:

s:`p`o`q`n`m!(`o`n;`n;`p`m;`;`)
order: {distinct reverse raze (raze x@) scan key x}
order[s]