Hello, I have a page with a "dataset1" (it has a sort of Category A-Z), the repeater is called"repeater2" and database called "Categories"( it is sorted by category alphabetically). The field I am trying to display has a key name of "category". I have tried many approaches and have read all of the articles I could find on the subject.
The code is as follows:
import { local } from 'wix-storage'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(() => { }); export function dataset1_ready_1() { wixData.query("Categories") .limit(300) .find() .then(results => { $w("#repeater2").data = Array.from(results.items.reduceRight((m, t) => m.set(t.category, t), new Map()).values()); }) }
The result are as follows: You will notice it is sorted until it reaches the 25th display on ???
It;s hard to understand what you're trying to do. You have a dataset but you don't use it, and instead you pull the data directly from the collection and then you process it in a complicated way that is not clear to outsiders.
Anyway, if you want the data to be sorted alphabetically, then add to your query:
//...code wixData.query("Categories") .ascending("category") .limit(300) .find() //code....