Plugin

Developer
Supported

VZ Picky

ExpressionEngine 2, ExpressionEngine 3

Back to this add-on's main page
View Other Add-ons From Eli Van Zoeren

     

You must be logged in to post.

Sort parameter not working correctly in some situations

Bug Report

sm9
sm9

Hi Eli,

I’ve noticed an issue with the sort parameter (in both the latest version and the one before it), where it doesn’t appear to be sorting all values alphabetically ascending, as I’d expect it to.

Here’s a screenshot showing an example of what I’m seeing: http://cl.ly/image/0H3j2p3u150H

Here’s my code for that:

<p><label>Town</label></p>
<
label><input type="checkbox" name="exclude" value="search:cf_event_town" /> None of</label>
<
p><select name="search:cf_event_town[]" multiple="multiple" size="15">
{exp:vz_picky field="cf_event_town" sort="alpha" hide_placeholder="yes"}
</select></p

It’s a strange one as the majority of the values are sorted correctly. But there’s some at the top that are out of place, and some at the very bottom that are out of place. I can’t figure out what’s different about these values though (i.e. whether they have different member groups, or statuses, or what), so thought I should report it in case you had any ideas.

Thanks,

Stephen

Eli Van Zoeren
# 1
Developer
Eli Van Zoeren

Would you try downloading and installing version 1.1.1 from https://github.com/elivz/vz_picky.ee_addon? I changed the sorting function to one that should be more accurate. I am guessing there might be spaces in front of the text in those fields, which aren’t visible in the list, but are still accounted for in the sorting.

Let me know if it works any better now.

sm9
# 2
sm9

Hi Eli,

Just tried that 1.1.1 and that resolved the issue I was having, so thanks for this. :-)

Also, you were correct about the space - I just picked an example that wasn’t sorting right and checked out 30 or so entries. The last one I checked had the space at the beginning, so that explains it.

Thanks,

Stephen

Eli Van Zoeren
# 3
Developer
Eli Van Zoeren

Glad to hear it! I’m using PHP’s natsort function now instead of just plain sort. It has better handling of things like spaces and numbers (so 12 will come after 5, for instance).

I’m closing this thread, but let me know if you run into anything else!