https://learninghub.kx.com/forums/topic/sort-a-table
I want to sort to sort the table below with c and d at the top, anyone know the best way to achieve this?
tab:([] sym:`a`b`c`d`e; x:5?10)
https://learninghub.kx.com/forums/topic/sort-a-table
I want to sort to sort the table below with c and d at the top, anyone know the best way to achieve this?
tab:([] sym:`a`b`c`d`e; x:5?10)
For normal sorting operations see:
q)tab:([] sym:`a`b`c`d`e; x:5?10) q)tab sym x ----- a 8 b 1 c 9 d 5 e 4 q)`sym xdesc tab sym x ----- e 4 d 5 c 9 b 1 a 8For your request perhaps rotate is what you are looking for
q)2 rotate tab sym x ----- c 9 d 5 e 4 a 8 b 1
q)t:([]sym:`a`b`c`d`e;x:til 5) q)t iasc`c`d?t`sym sym x ----- c 2 d 3 a 0 b 1 e 4
if you want to move the desired records to the top but want to preserve the order of the rest of the table