<p>Since you've overriden the <code>orderBy</code> parameter, you'll need to specify the second thing you want to order by. Structures store order and hierarchy using a few extra properties. You can use the <code>lft</code> property to sort the structures entries, meaning that the following code should solve your question.</p>
<pre><code>{% set entries = craft.entries
    .section('structure')
    .orderBy({ 'featured': SORT_DESC, 'lft': SORT_ASC })
    .all() 
%}
</code></pre>

CC BY-SA 4.0
2022-07-26T21:43:52.187Z
Thank you! Where do I find this `lft` property? I was looking all over the docs but couldn't find it… Thanks again!
Yann
CC BY-SA 4.0
2022-07-27T07:28:09.833Z
You'll find it in the `structureelements` database table, it is likely not documented because it is used internally, along with a few other properties, to store the element's position within the structure.
Ben Croker
CC BY-SA 4.0
2022-07-26T07:52:40.420Z
2022-07-26T07:52:40.420Z
Ben Croker
<p>I have a bunch of entries in a structure and I want to have all the &quot;featured&quot; entries returned first. Then everything else returned in the order set for that structure in the admin.</p>
<p>The answer to a similar question (<a href="https://craftcms.stackexchange.com/questions/35943/order-entries-query-by-a-featured-light-switch">Order Entries Query by a Featured Light Switch</a>) works well for channels, but not for structures…</p>
<pre><code>craft.entries().section('mySection').orderBy('featured DESC').all()
</code></pre>
<p>☝️ This seems to be defaulting to <code>postDate</code> as a &quot;second&quot; parameter, as opposed to &quot;the order defined by the section&quot; like the <a href="https://craftcms.com/docs/3.x/entries.html#orderby" rel="nofollow noreferrer">documentation seems to indicate</a> it should do for a structure.</p>
<p>Is this a bug, or is there a way to explicitly order by the structure's ordering in a second parameter?</p>
<p>Thanks!</p>

<craft3>
Order entries query of a structure by lightswitch field
# Order entries query of a structure by lightswitch field

(Asked by: username_0 on 2022-07-25)

I have a bunch of entries in a structure and I want to have all the "featured" entries returned first. Then everything else returned in the order set for that structure in the admin.
The answer to a similar question (Order Entries Query by a Featured Light Switch) works well for channels, but not for structures…
craft.entries().section('mySection').orderBy('featured DESC').all()

☝️ This seems to be defaulting to postDate as a "second" parameter, as opposed to "the order defined by the section" like the documentation seems to indicate it should do for a structure.
Is this a bug, or is there a way to explicitly order by the structure's ordering in a second parameter?
Thanks!

**Tags:** craft3

---

## 1 answers

### Answer by username_1 on 2022-07-26. Score: 2

Since you've overriden the orderBy parameter, you'll need to specify the second thing you want to order by. Structures store order and hierarchy using a few extra properties. You can use the lft property to sort the structures entries, meaning that the following code should solve your question.
{% set entries = craft.entries
    .section('structure')
    .orderBy({ 'featured': SORT_DESC, 'lft': SORT_ASC })
    .all() 
%}

> **Comments:**
> **username_0**: Thank you! Where do I find this `lft` property? I was looking all over the docs but couldn't find it… Thanks again!  
> **username_1**: You'll find it in the `structureelements` database table, it is likely not documented because it is used internally, along with a few other properties, to store the element's position within the structure.  

---

