# Sort relation valuelist

**URL:** <https://forum.servoy.com/t/sort-relation-valuelist/15186>\
**Category:** Classic Servoy\
**Created:** [December 15, 2011, 4:06pm UTC](https://forum.servoy.com/t/sort-relation-valuelist/15186 "2011-12-15T16:06:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuanMartin](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@JuanMartin](https://forum.servoy.com/u/JuanMartin)\
**Post date:** [December 15, 2011, 4:06pm UTC](https://forum.servoy.com/t/sort-relation-valuelist/15186/1 "2011-12-15T16:06:30Z")

</div>

Hi  
I have a valuelist through a relation  
The first option is for select the Id and the second is for show the name  
In a table viewe(locked) form, I need sort by the name when I click on the head of the filed but It´s sort by the Id and not by the name  
Any idea.

Thanks

Servoy 5.2.9  
PostgreSql

 ![sort.JPG](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/b/bbf4c1485ed033142646e8a93363b03a55ebb402.jpeg)

---

<div class="post-metadata">

**Author:** ![Roberto\_Blasco](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Roberto\_Blasco](https://forum.servoy.com/u/Roberto_Blasco)\
**Post date:** [December 15, 2011, 5:23pm UTC](https://forum.servoy.com/t/sort-relation-valuelist/15186/2 "2011-12-15T17:23:40Z")

</div>

Hi JuanMartin

Maybe is obvious, but … have you tried to set the **initialSort** property int the table form where the data is displayed?

Best regards. Roberto Blasco.

---

<div class="post-metadata">

**Author:** ![Roberto\_Blasco](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Roberto\_Blasco](https://forum.servoy.com/u/Roberto_Blasco)\
**Post date:** [December 15, 2011, 5:28pm UTC](https://forum.servoy.com/t/sort-relation-valuelist/15186/3 "2011-12-15T17:28:17Z")

</div>

Forget it Juan Martin …

I thought you were talking about the data showed in the table …

Did you try to recover the data through a global method instead a relation?

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [December 16, 2011, 11:33am UTC](https://forum.servoy.com/t/sort-relation-valuelist/15186/4 "2011-12-16T11:33:31Z")

</div>

JuanMartin,

This is a new feature in Servoy 6.1  
When a field is shown via a value list (table or related), table view sort will work on the display value in stead of the underlying dataprovider.

For Servoy \<=6.0 you can use the onSortCommand on the form.

Rob
