2

Sanity.io is awesome! But as I'm just beginning, I cannot find some things yet I know in e.g. MySQL. According to the GROQ cheat sheet I should be able to randomly sort and slice (LIMIT + OFFSET in MySQL) by giving this query:

  // BEWARE! This returns 10 random documents, ordered ascendingly by _createdAt
  *[_type == "movie"][0..9] | order(_createdAt asc)

However this does not randomly sort. The comment doesn't make sense also, because I would expect this to just pick the first 10 items based on creation time.

Anyone found out yet how to sort randomly? And, while we're at it, can I sort randomly with a seed? In MySQL SELECT * FROM your_table ORDER BY RAND(351); would do just that

Jos
  • 1,387
  • 1
  • 13
  • 27

1 Answers1

2

The documentation is using random somewhat colloquially – random here just means non-determined, not randomly sorted.