Say I have a column of bid price and bid size
time bid bid_size bid_book
11:00 1 4 3 2 100 100 200 300 CBOE
NYSEARCA
AMEX
12:00 1 1 3 2 100 200 300 100 CBOE
NYSEARCA
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 bid bid_size bid_book
11:00 1 2 3 4 100 300 200 100 CBOE
AMEXARCA
NSYE
12:00 1 1 2 3 100 200 100 300 CBOE
NYSEAMEX
ARCA
Any help would be appreciated?