Sort of sorts

2 Oct 2014 | , ,
Share on:

numbers

A few more sort idioms which don’t really translate over to q so well as more is just built in.

17 – Descending ordinals (ranking, all different)

q)x:15 16 13 18 14 11 12
q)iasc idesc x
2 1 4 0 3 6 5

18 & 19. Sort ascending by internal alphabet

q)w:("once";"more";"into")
q)w
"once"
"more"
"into"
q)asc w
"into"
"more"
"once"
q)

Or if you need to ignore case:

q)w2:("once";"More";"into")
q)w2
"once"
"More"
"into"
q)asc w2
"More"
"into"
"once"
q)w[iasc lower w]
"into"
"more"
"once"
q)

SUGGESTED ARTICLES

Kx Product Insights: Analyst for Kx IDE

3 Oct 2018 | , , ,

By Ben Jeffery Introduction This article examines how the features of Analyst for Kx help developers and analysts write code in kdb+. In previous articles in this series, we have ingested taxi and weather data into kdb from multiple sources, and used visual techniques to gain some insight into the data. This article will outline […]