<p>This will now work as of <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/updates#release-v2.2.0" rel="nofollow">Sprout Forms v2.2.0</a>:</p>

<pre><code>{# Ordering #}
{% for formEntry in craft.sproutForms.entries.formHandle('contact').order('address desc') %}
  ...
{% endfor %}

{# Filtering #}
{% for formEntry in craft.sproutForms.entries.formHandle('contact').firstName('Zoe') %}
  ...
{% endfor %#}
</code></pre>

CC BY-SA 3.0
2016-02-05T09:38:04.430Z
I've updated, but can't test it because now it produces an error in the assets field. see my support mail
noregt
CC BY-SA 3.0
2016-02-06T10:39:44.003Z
Updated to 2.2.1 and everything works like expected now :-)
noregt
CC BY-SA 3.0
2016-02-05T02:26:50.257Z
2016-02-06T16:37:31.453Z
2016-02-06T16:37:31.453Z
Ben Parizek
<p>It seams, that the columns for the form values are not part of the sql, that's why it never will work like this. Maybe it works in upcomming versions of the Sprout Forms plugin. </p>

<p>As a workaround you can use the SuperSort Plugin. With this plugin it's possible to sort your form entries like you need it.</p>

<p>Step 1 -> Download and Install SuperSort Plugin -> <a href="https://topshelfcraft.com/lagniappe/supersort" rel="nofollow">https://topshelfcraft.com/lagniappe/supersort</a>
Step 2 -> Filter your form entries like this:</p>

<pre><code>{% set formEntries = craft.sproutForms.entries.formHandle('contact')%}    
{% set formEntriesSort = formEntries | supersort('sortAs', '{address | lower}') %}

{% for formEntry in formEntriesSort %}
   {{ formEntry.address }}&lt;br&gt;
{% endfor %}
</code></pre>

<p>Like this it should work!</p>

CC BY-SA 3.0
2016-01-18T11:17:44.933Z
This works! How is it that Sprout Forms entries are not part of sql? Could you explain this a bit more and why supersort does work? I'm trying to understand this...
noregt
CC BY-SA 3.0
2016-01-18T11:24:39.407Z
Also what does 'sortAs' do (not explained on the plugin page)? Sorry for the basic questions.
noregt
CC BY-SA 3.0
2016-01-18T21:52:35.553Z
Maybe because of better performance the SQL does not include all the fields. But normaly the plugin should add the fields automaticly if you add such a field as orderBy statement. For deeper understanding you need to analyze the code. Have you tried to contact the Sprout Form Support about this issue? Maybe it's a bug...
Tom Bauer
CC BY-SA 3.0
2016-01-18T22:03:38.440Z
About the sortAs option: Like i understand*, supersort render first the given Twig-Variable (the second parameter) for all your form.address values and after it use a simple php sort (http://php.net/manual/en/function.sort.php) for sorting these values and the associated Array.

*i did not a deep review of the plugin...
Tom Bauer
CC BY-SA 3.0
2016-01-20T20:49:30.110Z
Just got an answer from the developers and it's a bug indeed. Will be fixed in the next release, thanks for the help!
noregt
CC BY-SA 3.0
2016-01-17T14:21:56.830Z
2016-01-17T14:21:56.830Z
Tom Bauer
<p>For some reason Sprout Forms entries will not accept the usual order by field handle setup. When I want to order the contact entries by address for instance:</p>

<pre><code>{% for formEntry in craft.sproutForms.entries.formHandle('contact').order('address') %}
    {{formEntry.address}}
{% endfor %}
</code></pre>

<p>I get the error:</p>

<blockquote>
  <p>Column not found: 1054 Unknown column 'address' in 'order clause'</p>
</blockquote>

<p>This field does exist. If I remove 'order', it parses the field</p>

CC BY-SA 3.0
2016-01-15T17:42:14.003Z
Been trying it with mysql in Twig like "SELECT * FROM `craft_sproutformscontent_contact` ORDER BY `craft_sproutformscontent_contact`.`field_address` ASC" but I was not able to get the right syntax in twig
noregt
CC BY-SA 3.0
2016-01-06T10:08:25.333Z
Apparently Sprout Forms has its own DB table. So not under 'craft_content' but under 'craft_sproutformscontent_contact' when the form is 'contact. Maybe that is the cause?'
noregt
<entries><plugin-sproutforms><order>
Order Sprout Forms by field handle returns an error
# Order Sprout Forms by field handle returns an error

(Asked by: username_0 on 2016-01-06)

For some reason Sprout Forms entries will not accept the usual order by field handle setup. When I want to order the contact entries by address for instance:
{% for formEntry in craft.sproutForms.entries.formHandle('contact').order('address') %}
    {{formEntry.address}}
{% endfor %}

I get the error:

Column not found: 1054 Unknown column 'address' in 'order clause'

This field does exist. If I remove 'order', it parses the field

**Tags:** entries, plugin-sproutforms, order
> **Comments:**
> **username_0**: Apparently Sprout Forms has its own DB table. So not under 'craft_content' but under 'craft_sproutformscontent_contact' when the form is 'contact. Maybe that is the cause?'  
> **username_0**: Been trying it with mysql in Twig like "SELECT * FROM `craft_sproutformscontent_contact` ORDER BY `craft_sproutformscontent_contact`.`field_address` ASC" but I was not able to get the right syntax in twig  

---

## 2 answers

### Answer by username_1 on 2016-02-05. Score: 2 | Accepted answer

This will now work as of Sprout Forms v2.2.0:
{# Ordering #}
{% for formEntry in craft.sproutForms.entries.formHandle('contact').order('address desc') %}
  ...
{% endfor %}

{# Filtering #}
{% for formEntry in craft.sproutForms.entries.formHandle('contact').firstName('Zoe') %}
  ...
{% endfor %#}

> **Comments:**
> **username_0**: I've updated, but can't test it because now it produces an error in the assets field. see my support mail  
> **username_0**: Updated to 2.2.1 and everything works like expected now :-)  

---

### Answer by username_2 on 2016-01-17. Score: 2

It seams, that the columns for the form values are not part of the sql, that's why it never will work like this. Maybe it works in upcomming versions of the Sprout Forms plugin. 
As a workaround you can use the SuperSort Plugin. With this plugin it's possible to sort your form entries like you need it.
Step 1 -> Download and Install SuperSort Plugin -> https://topshelfcraft.com/lagniappe/supersort
Step 2 -> Filter your form entries like this:
{% set formEntries = craft.sproutForms.entries.formHandle('contact')%}    
{% set formEntriesSort = formEntries | supersort('sortAs', '{address | lower}') %}

{% for formEntry in formEntriesSort %}
   {{ formEntry.address }}
{% endfor %}

Like this it should work!

> **Comments:**
> **username_0**: This works! How is it that Sprout Forms entries are not part of sql? Could you explain this a bit more and why supersort does work? I'm trying to understand this...  
> **username_0**: Also what does 'sortAs' do (not explained on the plugin page)? Sorry for the basic questions.  
> **username_2**: Maybe because of better performance the SQL does not include all the fields. But normaly the plugin should add the fields automaticly if you add such a field as orderBy statement. For deeper understanding you need to analyze the code. Have you tried to contact the Sprout Form Support about this issue? Maybe it's a bug...  
> **username_2**: About the sortAs option: Like i understand*, supersort render first the given Twig-Variable (the second parameter) for all your form.address values and after it use a simple php sort (http://php.net/manual/en/function.sort.php) for sorting these values and the associated Array.  *i did not a deep review of the plugin...  
> **username_0**: Just got an answer from the developers and it's a bug indeed. Will be fixed in the next release, thanks for the help!  

---

