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)

© 2018 Kx Systems
Kx® and kdb+ are registered trademarks of Kx Systems, Inc., a subsidiary of First Derivatives plc.

SUGGESTED ARTICLES

Kx for IoT in Asia with kdb+

Kx and the Internet of Things Asia

21 Apr 2017 | , , , ,

Adoption of connected devices and Internet of Things data analysis has become a compelling business imperative for companies and countries around the world. In Asia, the IoT revolution has unique characteristics reflecting the infrastructure and politics of the region. The conference is fittingly held in Singapore, which is striving to become the world’s first Smart City.

kdb+/q adverbs word cloud Nusa Znderl

Enhancing Your kdb+/q Toolkit: Real World Examples of Adverbs

12 Apr 2017 | , , , ,

Nuša Žnuderl’s latest blog post uses five real-world examples to demonstrate how kdb+/q coders can improve their results by using adverbs and not using looping constructs. Long-term the benefit is vastly improved performance from doing things in the “q way.” In her blog Nuša writes: “Similar to the English language, adverbs in q augment operations to allow an application on lists. They make code shorter, clearer and almost always more efficient than the alternative loopy modus operandi – all of which are qualities that differentiate code written by proficient q users from the rest.”

kdb+/q taxi demo benchmark

Kx 1.1 billion taxi ride benchmark highlights advantages of kdb+ architecture

25 Jan 2017 | , , ,

Stellar performance in third-party benchmarks is a tradition at Kx, and now we can add a new benchmark to the list, the taxi ride benchmark developed by Mark Litwintschik. This latest benchmark queries a 1.1 billion New York City taxi ride dataset. Our results were over four orders of magnitude faster than any other CPU technology and comparable to GPU-based code.