# Hi guys, how can I sort a table? 

**URL:** <https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [May 17, 2020, 8:04am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834 "2020-05-17T08:04:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucatag1901](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lucatag1901/32/19198_2.png) [@lucatag1901](https://forum.wixstudio.com/u/lucatag1901)\
**Post date:** [May 17, 2020, 8:04am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/1 "2020-05-17T08:04:07Z")

</div>

I have built this table with 8 columns and 100 rows. I need to sort each column so users can rank column easily with a click of a button. Attached is the table screenshot.

 ![](https://us1.discourse-cdn.com/wix/original/3X/4/e/4ef117c10bf15dcf1a412fcc1b705f37d6771200.png)

Any help is much appreciated.  
Thanks,  
Luca

---

<div class="post-metadata">

**Author:** ![\_or](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_or/32/1004_2.png) [@\_or](https://forum.wixstudio.com/u/_or)\
**Post date:** [May 17, 2020, 1:45pm UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/2 "2020-05-17T13:45:29Z")

</div>

Hi,  
Is the table connected to a dataset? if it is you can sort the database based on the table field that was clicked, use the [setSort()](https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setSort) function.  
You can also sort the rows with your costume code and use [table.rows](https://www.wix.com/corvid/reference/$w.Table.html#rows) to set the new order of the rows.

---

<div class="post-metadata">

**Author:** ![cakandari](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/cakandari/32/17780_2.png) [@cakandari](https://forum.wixstudio.com/u/cakandari)\
**Post date:** [May 17, 2020, 3:56pm UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/3 "2020-05-17T15:56:49Z")

</div>

You have to short ‘dataset’ by using filter option in dataset.

---

<div class="post-metadata">

**Author:** ![lucatag1901](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lucatag1901/32/19198_2.png) [@lucatag1901](https://forum.wixstudio.com/u/lucatag1901)\
**Post date:** [May 17, 2020, 5:59pm UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/4 "2020-05-17T17:59:30Z")

</div>

Hi, I am not sure I understand. Can you please show me or give me more details please?

---

<div class="post-metadata">

**Author:** ![cakandari](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/cakandari/32/17780_2.png) [@cakandari](https://forum.wixstudio.com/u/cakandari)\
**Post date:** [May 18, 2020, 2:26am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/5 "2020-05-18T02:26:20Z")

</div>

if you want sort by tapping header section then it is inbuilt in wix table. just tap for a while and it will show option of filter. If you want to put some sort button you need use of corvid. If you want to show sorted columns you simply go to the setting of dataset and there on downside you will find setting filter option. There you can set multiple sorting filters.

---

<div class="post-metadata">

**Author:** ![lucatag1901](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lucatag1901/32/19198_2.png) [@lucatag1901](https://forum.wixstudio.com/u/lucatag1901)\
**Post date:** [May 18, 2020, 7:43am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/6 "2020-05-18T07:43:20Z")

</div>

Hi, yes I want to put some sort buttons using Corvid. I have tried to put some code in the dev tools but didn’t work. I have also tried using some of the codes I have seen in this forum and also sadly didn’t work.  
I know how to filter or sort within the table, but this only shows in the dataset, not on the live table.  
How can I add sorting buttons with Corvid?

---

<div class="post-metadata">

**Author:** ![mvveiga](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mvveiga/32/122599_2.png) [@mvveiga](https://forum.wixstudio.com/u/mvveiga)\
**Post date:** [May 19, 2020, 3:03am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/7 "2020-05-19T03:03:45Z")

</div>

Check the javascript Array.sort() with callback function. Rows on table are array.

---

<div class="post-metadata">

**Author:** ![lucatag1901](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lucatag1901/32/19198_2.png) [@lucatag1901](https://forum.wixstudio.com/u/lucatag1901)\
**Post date:** [May 19, 2020, 10:44am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/8 "2020-05-19T10:44:53Z")

</div>

I have never used JS before, so can you please talk to me like a 5 years old kid? I would need the idiot guide on to build the code for this table, please

---

<div class="post-metadata">

**Author:** ![user1041](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/user1041/32/85900_2.png) [@user1041](https://forum.wixstudio.com/u/user1041)\
**Post date:** [December 15, 2023, 7:11am UTC](https://forum.wixstudio.com/t/hi-guys-how-can-i-sort-a-table/21834/9 "2023-12-15T07:11:31Z")

</div>

Can we get a built in sort order “random” through the dataset settings?
