# Why kdb does not support sorting dynamically(like java TreeMap, sql

**URL:** <https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 10, 2020, 9:30am UTC](https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032 "2020-07-10T09:30:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NDTM\_idea](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@NDTM\_idea](https://forum.kx.com/u/NDTM_idea)\
**Post date:** [July 10, 2020, 9:30am UTC](https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032/1 "2020-07-10T09:30:00Z")

</div>

I wan to use kdb to maintains my order book, the order book need keep sorted after insert/update/delete

---

<div class="post-metadata">

**Author:** ![jamie\_halligan](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jamie\_halligan](https://forum.kx.com/u/jamie_halligan)\
**Post date:** [July 17, 2020, 2:29pm UTC](https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032/2 "2020-07-17T14:29:00Z")

</div>

How are you sorting the order book? Kdb+ systems are typically designed around time series data or any other data that is received in some sorted order and does not have to have elements deleted/inserted mid-table often, if ever. Due to the way Kdb stores table data any time a table is modified such that the sorted attribute has to be removed it will take some time to sort the data again. It may be worth trying to find a solution that doesn’t require sorting every time.&nbsp;

---

<div class="post-metadata">

**Author:** ![felix1](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@felix1](https://forum.kx.com/u/felix1)\
**Post date:** [July 22, 2020, 10:57am UTC](https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032/3 "2020-07-22T10:57:00Z")

</div>

just use a grouped table or a dictionary:

o:`g#([]ord:`s$();pirce:`float$();size:`int$())

>

---

<div class="post-metadata">

**Author:** ![Attila](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Attila](https://forum.kx.com/u/Attila)\
**Post date:** [July 23, 2020, 9:39am UTC](https://forum.kx.com/t/why-kdb-does-not-support-sorting-dynamically-like-java-treemap-sql/12032/4 "2020-07-23T09:39:00Z")

</div>

https://github.com/KxSystems/kdb/blob/master/e/book.q

might be helpful

&nbsp; &nbsp;Attila

>
