Answers.Body: <p>Having just stumbled across this issue myself, I found that in the orderBy parameter that while 'lastName' didn't order correctly, 'lastname' did.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-24T19:46:35.443Z
Answers.Text: Weird - but it works!
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-06T15:56:04.937Z
Answers.Text: Ahh... probably the database is configured to use a case-sensitive collation.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-23T16:39:05.537Z
Answers.LastActivityDate: 2023-01-23T16:39:05.537Z
Answers.UserDisplayName: cuppanukka
Answers.Body: <p>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:</p>
  
  <pre><code>{% set users = craft.users.groupId(1).orderBy('lastName asc') %}
  
  &lt;ul&gt;
      {% for user in users %}
          &lt;li&gt;{{ user.lastName }}, {{ user.firstName }}&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>Gives:</p>
  
  <ul>
  <li>Aardvark, Adam</li>
  <li>Meadows, Marc</li>
  <li>Zimmerman, Bob</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-16T02:05:43.237Z
Answers.Text: Weird. I checked it pretty thoroughly before giving up.
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-16T02:52:42.083Z
Answers.Text: Are you using PostgreSQL by chance?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-16T15:56:11.080Z
Answers.Text: No, MySQL is the DB.
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-18T05:17:30.593Z
Answers.Text: in that case, ¯\_(ツ)_/¯
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-15T22:35:00.343Z
Answers.LastActivityDate: 2019-11-15T22:35:00.343Z
Answers.UserDisplayName: Brad Bell
Body: <p><strong>Craft 3.3.13</strong></p>
  
  <p>This query does not order users correctly.</p>
  
  <pre><code>{% set users = craft.users.groupId(3).orderBy('lastName asc') %}
  </code></pre>
  
  <p>Bug?</p>
  
Tags: <users><query><elementquery>
Title: Simple user query with orderBy not working
ThreadText: # Simple user query with orderBy not working
  
  (Asked by: username_0 on 2019-11-14)
  
  **Craft 3.3.13**
  
  This query does not order users correctly.
  
  ```
  {% set users = craft.users.groupId(3).orderBy('lastName asc') %}
  
  ```
  
  Bug?
  
  **Tags:** users, query, elementquery
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-01-23. Score: 2 | Accepted answer
  
  Having just stumbled across this issue myself, I found that in the orderBy parameter that while 'lastName' didn't order correctly, 'lastname' did.
  
  > **Comments:**
  > **username_0**: Weird - but it works!  
  > **username_2**: Ahh... probably the database is configured to use a case-sensitive collation.  
  
  ---
  
  ### Answer by username_2 on 2019-11-15. Score: 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
  
  > **Comments:**
  > **username_0**: Weird. I checked it pretty thoroughly before giving up.  
  > **username_2**: Are you using PostgreSQL by chance?  
  > **username_0**: No, MySQL is the DB.  
  > **username_2**: in that case, ¯\_(ツ)_/¯  
  
  ---
  
  