Is anyone else struggling with the updated Default Sort Order that changed from Alphabetical to Newest Created on Feb 5/2025? Shopify support is telling me there is no way to change my default sort order back to Alphabetical - the best recommendation they offered was to hire a third party to change the code in the back end to customize my Shopify site. I’m frustrated with the recommendation that I need to spend more money to have my shop set up the way that works for me.
Hi @TKEQShop ,
You may need to make a small change in the code to get this done:
Add Custom Code to Change Default Sort Order1. Go to the Theme Editor:
- In Shopify Admin, navigate to Online Store > Themes.
- Click Actions > Edit Code for your active theme.
-
Locate the Collection Template:
- Open the collection.liquid file (or main-collection.liquid in Dawn and other modern themes).
-
Find the Sort Order Code:
- Look for code like {% assign sorted_products = collection.products %} or collection.products | sort
- Replace with {% assign sorted_products = collection.products | sort: ‘title’ %}
-
Save, this should fix it for you.
You can also use apps such as Collection Sort by Power Tools or Smart Collection Filters & Search to have more control on your filtering.
Hey @TKEQShop ,
You can modify your Shopify theme to automatically sort products alphabetically by adding a small code snippet to your theme files. This ensures a consistent alphabetical sorting experience without requiring ongoing maintenance or third-party apps.
The solution involves adding either a JavaScript snippet to your theme.liquid file or a Liquid-based solution to your collection-template.liquid file. This modification automatically redirects visitors to an alphabetically sorted view when they land on your collection pages.
How to Implement:1. Go to Online Store > Themes
- Click “Actions” > “Edit Code”
- Find your theme.liquid file
- Add the provided JavaScript snippet just before the closing tag
- Save your changes
I’m sharing this because such basic functionality shouldn’t require hiring a developer or paying for an app. While Shopify’s decision to change the default sorting behavior makes sense in some cases, restoring alphabetical sorting should be simple and accessible.
JavaScript Solution (Add to theme.liquid just before )
<script>
document.addEventListener('DOMContentLoaded', function() {
// Check if the current page is a collection page
if (window.location.pathname.includes('/collections/')) {
// Get the current sorting parameter
const urlParams = new URLSearchParams(window.location.search);
const currentSort = urlParams.get('sort_by');
// Redirect to alphabetical sorting if no sort parameter is set
if (!currentSort) {
window.location.href = window.location.pathname + '?sort_by=title-ascending';
}
}
});
</script>
Alternative Liquid Solution (Add to collection-template.liquid)
{% if collection.sort_by == blank %}
<script>
window.location.href = '{{ collection.url }}?sort_by=title-ascending';
</script>
{% endif %}
This quick fix restores alphabetical sorting without the need for third-party solutions or ongoing maintenance.
Cheers!
Shubham | Untechnickle
Thank you so much for this - to confirm this is to do with my products page on my Shopify Account - I don’t have any problems with how things are appearing to my customers. This is more an internal problem. I will give this a try if so
Hi Natalie,
Thank you for your follow-up email! I hope you’re doing fantastic.
Please ignore my previous solution - ;et me offer you a simple, free solution that affects only your backend admin panel - not your customer-facing store. This method uses a browser extension called Tampermonkey to automatically sort your products alphabetically in the admin panel.
1. Install the Tampermonkey Extension:
-
For Chrome:
Visit the Chrome Web Store and search for “Tampermonkey”. -
For Firefox:
Visit Firefox Add-ons and search for “Tampermonkey”.
2. Add the Sorting Script:
- Click the Tampermonkey icon in your browser (it looks like a black square with two circles).
- Select “Create a new script”.
- Delete any default code in the editor.
- Copy and paste the following code:
// ==UserScript==
// @name Shopify Admin Automatic Alphabetical Sort
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Automatically sort Shopify admin product list alphabetically
// @author You
// @match https://admin.shopify.com/store/*/products*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function sortProductsAlphabetically() {
const tableBody = document.querySelector('.Polaris-IndexTable__Table tbody');
if (!tableBody) {
console.log('Table body not found, waiting...');
return false;
}
const rows = Array.from(tableBody.querySelectorAll('tr[id^="gid://shopify/Product/"]'));
if (rows.length <= 1) {
console.log('Not enough rows to sort');
return false;
}
rows.sort((a, b) => {
const titleA = a.querySelector('a[data-primary-link="true"] span')?.textContent.trim().toLowerCase() || '';
const titleB = b.querySelector('a[data-primary-link="true"] span')?.textContent.trim().toLowerCase() || '';
return titleA.localeCompare(titleB);
});
rows.forEach(row => tableBody.appendChild(row));
return true;
}
function observeProductList() {
const productTable = document.querySelector('.Polaris-IndexTable');
if (!productTable) {
setTimeout(observeProductList, 1000);
return;
}
const observer = new MutationObserver((mutations) => {
setTimeout(() => {
sortProductsAlphabetically();
}, 500);
});
observer.observe(productTable, {
childList: true,
subtree: true
});
sortProductsAlphabetically();
}
function attemptInitialSort(attempts = 0) {
if (attempts > 10) return;
if (!sortProductsAlphabetically()) {
setTimeout(() => attemptInitialSort(attempts + 1), 1000);
} else {
observeProductList();
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => attemptInitialSort());
} else {
attemptInitialSort();
}
window.addEventListener('popstate', () => attemptInitialSort());
window.addEventListener('pushstate', () => attemptInitialSort());
window.addEventListener('replacestate', () => attemptInitialSort());
})();
3. Save the Script:
- Click File > Save, or press Ctrl+S (Cmd+S on Mac).
- Refresh your Shopify admin products page.
Summary:
- Scope: This script only affects how products are displayed in your admin panel.
- Impact: It does not change anything on your customer-facing store.
- Automation: Products are automatically sorted alphabetically every time you view them.
- Compatibility: It works across all product views (All, Active, Draft, etc.).
- Ease of Use: No coding knowledge or paid services are required.
If you ever want to disable the alphabetical sorting, simply:
- Click the Tampermonkey icon.
- Toggle the switch next to “Shopify Admin Automatic Alphabetical Sort”.
Please let me know if you need any help with the installation or have any questions, I’m happy to clarify any steps or assist with troubleshooting.
Best regards,
Shubham | Untechnickle
P.S. Remember to refresh your Shopify admin page after installing the script for the changes to take effect.
I second this I am getting so frustrated for the new automatic sort order in the admin for products and also for purchase orders. Shopify there needs to be a way for us to set our preferences for the default sort order the new ones are wasting our time having to resort every time we use these pages.
Yes! This is so frustrating. I don’t understand why this change was made to begin with, when alphabetical order should always be the default.
Frustrating is an understatement. Incomprehensible!!. Restore the default setting A-Z per script? Foolish. Did anyone ask for this? Add an option for A-Z or by date, as simple as that. We have businesses to run !