Re: [personal kdb+] How can I create a conditional sort?

You can pass multiple columns into xasc

timepos xasc t

also, sorting is stable so you can go

time xasc pos xdesc t

failing those, you can massage your indices something like 

t (exec i from t where 500=abs pos),exec i from t where 500<>abs pos

to put all the 500s first then the rest of the records.

Not sure what you’re trying to do because it looks like your email is incomplete.


From: personal-kdbplus@googlegroups.com <personal-kdbplus@googlegroups.com> on behalf of Roni Hoffman <hoffmanroni@gmail.com>
Sent: May 13, 2016 10:40 AM
To: Kdb+ Personal Developers
Subject: [personal kdb+] How can I create a conditional sort?
 

For example,

I have a table similar to

time pos

14:00:01.000 -500

14:00:02.000 -300

14:00:02.000 -200

14:00:02.000 0

14:00:02.000 -500

14:00:03.000 500

14:00:04.000 300

14:00:04.000 200

14:00:04.000 0

14:00:04.000 500


Submitted via Google Groups

what’s your condition?  you can sort a list by absolute value as 

  x iasc abs x