Answers.Body: <h3>Craft 2</h3>
  <p>Either of these should work (they are equivalent):</p>
  <pre><code>{% set entries = craft.entries.width('&gt; 0').section('windows').order('width') %}
  </code></pre>
  <p>or</p>
  <pre><code>{% set entries = craft.entries({
    section: 'windows',
    order: 'width',
    width: '&gt; 0'
  }) %}
  </code></pre>
  <p>The reason you are getting &quot;Array to string conversion&quot; error is that <a href="https://craftcms.com/docs/templating/elementcriteriamodel#find" rel="nofollow noreferrer">find</a> has turned your <a href="https://craftcms.com/docs/templating/elementcriteriamodel" rel="nofollow noreferrer">ElementCriteriaModel</a> into an array.</p>
  <h3>Craft 3</h3>
  <p><code>order</code> is now <code>orderBy</code></p>
  <p>Craft 3 Docs: <a href="https://craftcms.com/docs/3.x/element-queries.html" rel="nofollow noreferrer">Element Queries</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T08:48:28.803Z
Answers.Text: Yes! Thanks, this really works as it's supposed to, no plugins needed.
Answers.UserDisplayName: klaxon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-04-16T20:14:59.303Z
Answers.LastActivityDate: 2020-12-23T19:56:13.560Z
Answers.LastEditDate: 2020-12-23T19:56:13.560Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>Have you tried putting in 'width' instead of width?</p>
  
  <p>The order parameter expects a string, not an object, as it just needs to know the name of the field name to filter by.</p>
  
  <p>Final code would look like:</p>
  
  <pre><code>{% set entries = craft.entries.section('windows').find({'width':'&gt; 0'}).order('width') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-14T08:53:41.997Z
Answers.Text: Yes, but that ends with „Array to string conversion“ error.Thanks anyway.
  In the craft's docs there is written that only textual fields can be used to order. Wierd.
  So I have superSort plugin installed… and I can order by width field.
  But still believe that craft should do this naturaly. It does with assets.
Answers.UserDisplayName: klaxon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-12T21:54:56.150Z
Answers.LastActivityDate: 2016-04-12T21:54:56.150Z
Answers.UserDisplayName: Patrick Harrington
Body: <p>I'm new to craft so may it be a basic question, however I can't find an answer for it :-/</p>
  
  <p>I have custom field 'width' in my entry type defined as integer.
  What I need to achieve is quite simple:</p>
  
  <pre><code>{% set entries = craft.entries.section('windows').find({'width':'&gt; 0'}).order(width) %}
  </code></pre>
  
  <p>The important now is the .order part it's not working right now :-(. What is correct way to do this? I have found some plugins but I believe craft can do this somehow… It always does (so far).</p>
  
  <p>Thanks for any info on this.</p>
  
Tags: <templating><entries>
Title: Ordering entries by custom field (integer)
ThreadText: # Ordering entries by custom field (integer)
  
  (Asked by: username_0 on 2016-04-12)
  
  I'm new to craft so may it be a basic question, however I can't find an answer for it :-/
  
  I have custom field 'width' in my entry type defined as integer.
  What I need to achieve is quite simple:
  
  ```
  {% set entries = craft.entries.section('windows').find({'width':'> 0'}).order(width) %}
  
  ```
  
  The important now is the .order part it's not working right now :-(. What is correct way to do this? I have found some plugins but I believe craft can do this somehow… It always does (so far).
  
  Thanks for any info on this.
  
  **Tags:** templating, entries
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-16. Score: 3 | Accepted answer
  
  ### Craft 2
  
  Either of these should work (they are equivalent):
  
  ```
  {% set entries = craft.entries.width('> 0').section('windows').order('width') %}
  
  ```
  
  or
  
  ```
  {% set entries = craft.entries({
    section: 'windows',
    order: 'width',
    width: '> 0'
  }) %}
  
  ```
  
  The reason you are getting "Array to string conversion" error is that [find](https://craftcms.com/docs/templating/elementcriteriamodel#find) has turned your [ElementCriteriaModel](https://craftcms.com/docs/templating/elementcriteriamodel) into an array.
  
  ### Craft 3
  
  `order` is now `orderBy`
  
  Craft 3 Docs: [Element Queries](https://craftcms.com/docs/3.x/element-queries.html)
  
  > **Comments:**
  > **username_0**: Yes! Thanks, this really works as it's supposed to, no plugins needed.  
  
  ---
  
  ### Answer by username_2 on 2016-04-12. Score: 2
  
  Have you tried putting in 'width' instead of width?
  
  The order parameter expects a string, not an object, as it just needs to know the name of the field name to filter by.
  
  Final code would look like:
  
  ```
  {% set entries = craft.entries.section('windows').find({'width':'> 0'}).order('width') %}
  
  ```
  
  > **Comments:**
  > **username_0**: Yes, but that ends with „Array to string conversion“ error.Thanks anyway. In the craft's docs there is written that only textual fields can be used to order. Wierd. So I have superSort plugin installed… and I can order by width field. But still believe that craft should do this naturaly. It does with assets.  
  
  ---
  
  