1

Craft 3.3.13

This query does not order users correctly.

{% set users = craft.users.groupId(3).orderBy('lastName asc') %}

Bug?

2 Answers 2

2

Having just stumbled across this issue myself, I found that in the orderBy parameter that while 'lastName' didn't order correctly, 'lastname' did.

2
  • Weird - but it works!
    – 4midori
    Commented Jan 24, 2023 at 19:46
  • 1
    Ahh... probably the database is configured to use a case-sensitive collation.
    – Brad Bell
    Commented Feb 6, 2023 at 15:56
1

Just did a simple test on a fresh install of the latest Craft with 3 users in a user group using this code and the output was what I'd expect:

{% set users = craft.users.groupId(1).orderBy('lastName asc') %}

<ul>
    {% for user in users %}
        <li>{{ user.lastName }}, {{ user.firstName }}</li>
    {% endfor %}
</ul>

Gives:

  • Aardvark, Adam
  • Meadows, Marc
  • Zimmerman, Bob
4
  • Weird. I checked it pretty thoroughly before giving up.
    – 4midori
    Commented Nov 16, 2019 at 2:05
  • Are you using PostgreSQL by chance?
    – Brad Bell
    Commented Nov 16, 2019 at 2:52
  • No, MySQL is the DB.
    – 4midori
    Commented Nov 16, 2019 at 15:56
  • in that case, ¯_(ツ)_/¯
    – Brad Bell
    Commented Nov 18, 2019 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.