# Estate Agent example - add custom 'order by'

**URL:** <https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021>\
**Category:** CMS Development\
**Created:** [March 11, 2021, 10:53am UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021 "2021-03-11T10:53:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [March 11, 2021, 10:53am UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/1 "2021-03-11T10:53:58Z")

</div>

Hi I’ve been trying out the estate agent

example: [GitHub - HubSpot/cms-custom-objects-example · GitHub](https://designers.hubspot.com/docs/tutorials/how-to-build-a-real-estate-listing-with-hubdb)

I’ve got it working, however I want to adjust the order the items are displayed for example by bedrooms. Any idea how this is done?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [March 11, 2021, 12:53pm UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/2 "2021-03-11T12:53:52Z")

</div>

Hi @ben-duchy, you can use the orderBy property to order items:

`{% set queryparam = queryparam ~ '&orderBy=[bedrooms field]' %}{% for row in hubdb_table_rows('[id]', queryparam) %}{% endfor %}`

If you want to reverse the order use a minus sign before the field name like so:

`{% set queryparam = queryparam ~ '&orderBy=-[bedrooms field]' %} `

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [March 15, 2021, 1:09pm UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/3 "2021-03-15T13:09:13Z")

</div>

@piersg Is there a way to load the page with a pre-selected option? Currenlty the page starts with ‘show all’ but I want to remove this and start it with the 3rd item in the list.

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [March 11, 2021, 2:40pm UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/4 "2021-03-11T14:40:31Z")

</div>

Perfect, thanks @piersg 👍

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [March 15, 2021, 3:36pm UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/5 "2021-03-15T15:36:05Z")

</div>

@ben-duchy, when you say ‘show-all’ do you mean you have a select/dropdown list that is being used to filter the DB and you want to change the default option of that list? What are the items in that list that you’re using to filter? The number of bedrooms?

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [March 15, 2021, 3:46pm UTC](https://community.hubspot.com/t/estate-agent-example-add-custom-order-by/33021/6 "2021-03-15T15:46:39Z")

</div>

Hi @piersg thanks for coming back to me on this.  
Yes thats correct, the select list is being used to display different data, namely the different housing developments my employer has built for example London, Manchester, Leeds etc. As theres too much data to pull through (558 rows and growing), I want to remove the ‘show all’ from the list and start the original page load on a different option.

I’m aware I can remove the ‘Show All’ by simply commenting it out, but the page still shows everything when the page is loaded. I would ideally like to show another option by default.

\<form id=“filter” method=“get”\>  
\<select name=“type” form=“filter” onChange=“this.form.submit()”\>  
**\<option value=“show-all”\>Show All\</option\>**  
{% set types = hubdb\_table\_column(123456789, “type”).options %}  
{% for choice in types %}  
{% set type\_list = type\_list~choice.id|list%}  
{% if choice.id == request.query\_dict.type%}  
\<option selected=“selected” value=“{{ choice.id }}”\>{{ choice.name }}\</option\>  
{% else %}  
\<option value=“{{ choice.id }}”\>{{ choice.name }}\</option\>  
{% endif %}  
{% endfor %}  
\</select\>  
\<input id=“submit-button” type=“submit” value=“search”\>  
\</form\>
