Answers.Body: <p>Example query, replace handles of section and fields</p>
  <p>PAGE X</p>
  <pre><code>{% set query = craft.entries().section('cocktails').orderBy('inventionDate DESC') %}
  </code></pre>
  <p>PAGE Y</p>
  <pre><code>{% set query = craft.entries().section('cocktails').orderBy('score DESC') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-16T01:58:22.570Z
Answers.LastActivityDate: 2024-10-16T01:58:22.570Z
Answers.UserDisplayName: Prashant sharma
Body: <p>I want to sort an &quot;category page&quot; based on a field set in the entry.
  Eg. website about cocktails, on page x i want to sort by invention date and on page y I want to sort the cocktails based on their score.</p>
  <p>What is the most elegant way to set this up in craftcms?</p>
  
Tags: <entry><sorting><craft5>
Title: Entry field as sorting option
ThreadText: # Entry field as sorting option
  
  (Asked by: username_0 on 2024-10-11)
  
  I want to sort an "category page" based on a field set in the entry.
  Eg. website about cocktails, on page x i want to sort by invention date and on page y I want to sort the cocktails based on their score.
  
  What is the most elegant way to set this up in craftcms?
  
  **Tags:** entry, sorting, craft5
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-10-16. Score: 1
  
  Example query, replace handles of section and fields
  
  PAGE X
  
  ```
  {% set query = craft.entries().section('cocktails').orderBy('inventionDate DESC') %}
  
  ```
  
  PAGE Y
  
  ```
  {% set query = craft.entries().section('cocktails').orderBy('score DESC') %}
  
  ```
  
  
  ---
  
  