# Search Order in Reference Field

**URL:** https://discuss.tryton.org/t/search-order-in-reference-field/5200
**Category:** Developer
**Created:** [April 23, 2022, 6:21pm UTC](https://discuss.tryton.org/t/search-order-in-reference-field/5200 "2022-04-23T18:21:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [April 23, 2022, 6:21pm UTC](https://discuss.tryton.org/t/search-order-in-reference-field/5200/1 "2022-04-23T18:21:52Z")

</div>

I have a reference field. and May I know how to define sort order on this field?  
I had tried using order\_{field\_name}.

But due to the nature of reference field format is “model,id”. I do not know how to define query to make the join table.

Please help

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [April 25, 2022, 8:51am UTC](https://discuss.tryton.org/t/search-order-in-reference-field/5200/2 "2022-04-25T08:51:32Z")

</div>

Because Reference field target many different models, there is no real way to define an order on them. So the system orders only on the raw data value.

But of course you can try to implement one custom with the `order_<name>` method but you will have to make a join to each possible tables and create an expression out of all the joined tables. So it will look like the `Many2One.convert_order` but using a loop to make all the joins.
