# Linking vector columns

**URL:** <https://forum.kx.com/t/linking-vector-columns/12589>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [June 30, 2022, 3:59pm UTC](https://forum.kx.com/t/linking-vector-columns/12589 "2022-06-30T15:59:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MG41](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@MG41](https://forum.kx.com/u/MG41)\
**Post date:** [June 30, 2022, 3:59pm UTC](https://forum.kx.com/t/linking-vector-columns/12589/1 "2022-06-30T15:59:00Z")

</div>

Hi,

Is there a way to link vector columns so that when we do something like asc, the corresponding column will also re-arrage:

tbl:( sVec:((`b`c`a);(`c`a`b);(`a`b`c));sNum:((2 3 1);(3 1 2);(1 2 3))); tbl sVec sNum ----------- b c a 2 3 1 c a b 3 1 2 a b c 1 2 3 update sVec:asc’[sVec] from tbl sVec sNum ----------- a b c 2 3 1 a b c 3 1 2 a b c 1 2 3 Desired output (Where each symbol is linked to number in same vector position): tbl1 sVec sNum ----------- a b c 1 2 3 a b c 1 2 3 a b c 1 2 3

&nbsp;

Many thanks!

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [June 30, 2022, 4:09pm UTC](https://forum.kx.com/t/linking-vector-columns/12589/2 "2022-06-30T16:09:00Z")

</div>

iasc&nbsp;gives you the sorted idexes which you can use

q)update sVec:sVec(@)'iasc each sNum,asc each sNum from tbl sVec sNum ----------- a b c 1 2 3 a b c 1 2 3 a b c 1 2 3

&nbsp;

---

<div class="post-metadata">

**Author:** ![MG41](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@MG41](https://forum.kx.com/u/MG41)\
**Post date:** [June 30, 2022, 5:03pm UTC](https://forum.kx.com/t/linking-vector-columns/12589/3 "2022-06-30T17:03:00Z")

</div>

Nice solution, thank you!
