Answers.Body: <p>I am posting the answer of Craft Commerce Support in case somebody stumbles over the same thing:</p>
  
  <p>It is possible to order them differently if required. The code example below shows how to order them alphabetically by SKU.</p>
  
  <pre><code>{% set lineItems = cart.lineItems|sort((a,  b) =&gt; a.sku &lt;=&gt; b.sku)  %}
  &lt;ul&gt;
      {% for item in lineItems %}
          &lt;li&gt;{{ item.description }} - [{{ item.sku }}]&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks Nathaniel</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T12:11:46.380Z
Answers.LastActivityDate: 2019-11-20T12:11:46.380Z
Answers.UserDisplayName: outline4
Body: <p>As of Commerce 2.2 line items are ordered by date created.</p>
  
  <p>How can you order line items differently? </p>
  
  <p><code>{% for item in cart.lineItems.orderBy(’sku desc') %}</code> does not work… </p>
  
Tags: <plugin-craftcommerce2><ecommerce>
Title: Craft Commerce > 2.2: How can you order line items?
ThreadText: # Craft Commerce > 2.2: How can you order line items?
  
  (Asked by: username_0 on 2019-11-20)
  
  As of Commerce 2.2 line items are ordered by date created.
  
  How can you order line items differently?
  
  `{% for item in cart.lineItems.orderBy(’sku desc') %}` does not work…
  
  **Tags:** plugin-craftcommerce2, ecommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-11-20. Score: 3
  
  I am posting the answer of Craft Commerce Support in case somebody stumbles over the same thing:
  
  It is possible to order them differently if required. The code example below shows how to order them alphabetically by SKU.
  
  ```
  {% set lineItems = cart.lineItems|sort((a,  b) => a.sku <=> b.sku)  %}
  <ul>
      {% for item in lineItems %}
          <li>{{ item.description }} - [{{ item.sku }}]</li>
      {% endfor %}
  </ul>
  
  ```
  
  Thanks Nathaniel
  
  
  ---
  
  