🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

How to change the order of items in Sanity and display them correctly on a website.

14 replies
Last updated: Sep 24, 2022
Hello Everyone, help
I have a terrible problem with Sanity, can anybody help me?!
when I add items in each sanity section in my desired order, when displayed on my website, they are totally scrambled and out of order , this is what I posted, and next is what is displayed on my website, items are not in order, WHYY?!!
Sep 24, 2022, 10:03 AM
Do you order them in your query? The studio typically displays them in last updated order, but that’s not necessarily what your query does. You may need to be specific.
Sep 24, 2022, 10:46 AM
how can I change the order in my website?!! they dont change
Sep 24, 2022, 12:52 PM
I add them , but they dont show up in order that I added them
Sep 24, 2022, 12:53 PM
You can do that with the
function in your query.
Sep 24, 2022, 1:04 PM
in react? how?!
Sep 24, 2022, 1:10 PM
for instance, I add my publications in order in Sanity , but they appear scrambled. in Sanity I add them so there should be a solution in Sanity , is that right?!
Sep 24, 2022, 1:11 PM
In your query. The groq query.
Sep 24, 2022, 1:13 PM
Show me your groq query. 🙂
Sep 24, 2022, 1:13 PM
const Publications = () => { const [publications, setPublications] = useState([]);

useEffect(() => {
const query = '*[_type == "publications"]';

client.fetch(query).then((data) => {
}, []);

return (
<h2 className="head-text">Publications</h2>

{publications.map((publication) => (
<motion.div className="app__skills-exp-item">
<span className="p-text2">{publication.authors}</span>
<span className="p-text2">{publication.title}</span>
<span className="p-text3">{publication.journal}</span>


export default AppWrap(
MotionWrap(Publications, "app__skills"),
Sep 24, 2022, 1:17 PM
Just the groq query was enough. 🙂
Sep 24, 2022, 1:18 PM
This is how you‘d order your data when querying it:
*[_type == "publications"] | order(_updatedAt desc)
Sep 24, 2022, 1:18 PM
you mean I add _updateAt desc ?!!
Sep 24, 2022, 1:20 PM
order(_updatedAt desc)

Sep 24, 2022, 1:20 PM
After a pipe, yes. Like I’ve shown. You can also check the docs: https://www.sanity.io/docs/query-cheat-sheet#b5aec96cf56c
Sep 24, 2022, 1:21 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?