# Sorting without combining

**URL:** <https://forum.kx.com/t/sorting-without-combining/9819>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [May 13, 2015, 3:12pm UTC](https://forum.kx.com/t/sorting-without-combining/9819 "2015-05-13T15:12:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![varun\_umich](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@varun\_umich](https://forum.kx.com/u/varun_umich)\
**Post date:** [May 13, 2015, 3:12pm UTC](https://forum.kx.com/t/sorting-without-combining/9819/1 "2015-05-13T15:12:00Z")

</div>

Say I have a column of bid price and bid size

time &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bid\_size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bid\_book

11:00 &nbsp; &nbsp; &nbsp; &nbsp; 1 4 3 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 100 100 200 300 &nbsp; &nbsp; &nbsp; &nbsp; `CBOE`NYSE`ARCA`AMEX

&nbsp;12:00 &nbsp; &nbsp; &nbsp; &nbsp;1 1 3 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;100 200 300 100 &nbsp; &nbsp; &nbsp; &nbsp;`CBOE`NYSE`ARCA`AMEX

Now I would like to sort it in increasing or decreasing order and have the bid\_size aligned with the bids. Do note that if there are 2 bids that have the same price like the second row, I would want both the bids to be listed separately. Also notice how the bid book changes too accordingly. Below is the resultant table:

time &nbsp; &nbsp; &nbsp; &nbsp; bid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bid\_size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bid\_book

11:00 &nbsp; &nbsp; 1 2 3 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;100 300 200 100 &nbsp; &nbsp; &nbsp; &nbsp;`CBOE`AMEX`ARCA`NSYE

12:00 &nbsp; &nbsp; 1 1 2 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 100 200 100 300 &nbsp; &nbsp; `CBOE`NYSE`AMEX`ARCA

Any help would be appreciated?
