Answers.Body: <p>I've seen that before, if you look at the <code>sites</code> table in your DB, you'll see that a few sites might have their <code>sortOrder</code> set to 1. </p>
  
  <p>If you go to Settings → Sites → [the offending group] in your Control Panel, try to reset the order of your sites in there (drag/drop using the little handle to the right of each site row), it should stop them showing up in a random order on the front end.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-31T08:58:18.963Z
Answers.Text: Oliver, you hero! You are 100% correct, it was that these 10 sites all had sortOrder 1
Answers.UserDisplayName: John Stevens
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-31T08:14:26.340Z
Answers.LastActivityDate: 2019-05-31T08:14:26.340Z
Answers.UserDisplayName: Oli
Body: <p>We have 38 sites running, divided over 6 groups.
  But for some weird reason on showing the sites list, 10 sites are showing up random. How can we fix this, or how can we order the sites on 'name' or 'id'?</p>
  
  <pre><code>{% set sites = craft.app.sites.allsites() %}
  {% for site in sites %}
      {{ site.name }}&lt;br&gt;
  {% endfor %}
  </code></pre>
  
  <p><a href="https://i.sstatic.net/qwYvF.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qwYvF.gif" alt="enter image description here"></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-30T16:11:35.483Z
Comments.Text: Huh... looks like it's ordered by Site Group name ascending first, then Site sort order ascending second. Not real sure why that would change in between page refreshes. 
   https://github.com/craftcms/cms/blob/develop/src/services/Sites.php#L1214
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-31T06:26:10.327Z
Comments.Text: and .order() is not working on this either?
Comments.UserDisplayName: John Stevens
Tags: <craft3><multi-site><ordering>
Title: How to order Sites
ThreadText: # How to order Sites
  
  (Asked by: username_0 on 2019-05-30)
  
  We have 38 sites running, divided over 6 groups.
  But for some weird reason on showing the sites list, 10 sites are showing up random. How can we fix this, or how can we order the sites on 'name' or 'id'?
  
  ```
  {% set sites = craft.app.sites.allsites() %}
  {% for site in sites %}
      {{ site.name }}<br>
  {% endfor %}
  
  ```
  
  [![enter image description here](https://i.sstatic.net/qwYvF.gif)](https://i.sstatic.net/qwYvF.gif)
  
  **Tags:** craft3, multi-site, ordering
  
  > **Comments:**
  > **username_1**: Huh... looks like it's ordered by Site Group name ascending first, then Site sort order ascending second. Not real sure why that would change in between page refreshes.   https://github.com/craftcms/cms/blob/develop/src/services/Sites.php#L1214  
  > **username_0**: and .order() is not working on this either?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-05-31. Score: 5 | Accepted answer
  
  I've seen that before, if you look at the `sites` table in your DB, you'll see that a few sites might have their `sortOrder` set to 1.
  
  If you go to Settings → Sites → [the offending group] in your Control Panel, try to reset the order of your sites in there (drag/drop using the little handle to the right of each site row), it should stop them showing up in a random order on the front end.
  
  > **Comments:**
  > **username_0**: Oliver, you hero! You are 100% correct, it was that these 10 sites all had sortOrder 1  
  
  ---
  
  