> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: ascending(propertyName: Array) # Method package: wixData # Method menu location: wixData --> WixDataAggregate --> ascending # Method Link: https://dev.wix.com/docs/velo/apis/wix-data/wix-data-aggregate/ascending.md # Method Description: Adds a sort to an aggregation, sorting by the items or groups by the specified properties in ascending order. The `ascending()` function refines a `WixDataAggregate` to sort the resulting items or groups in ascending order. If you specify more than one property, `ascending()` sorts the results in ascending order by each property in the order they are listed. You can sort the following types: + Number: Sorts numerically. + Date: Sorts by date and time. + String: Sorts lexicographically, so `"abc"` comes after `"XYZ"`. + Reference: Compares by the ID of the referenced item as a String. If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items that do not have a value for the specified sort property are ranked lowest. > **Note:** Aggregations can only be used on collections you have created. They cannot be used on [Wix App Collections](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Add an ascending sort to an aggregation ```javascript let newAggregate = aggregate.ascending("state", "city"); ``` ## Create an aggregation, add an ascending sort, and run it ```javascript import wixData from 'wix-data'; // ... wixData.aggregate("PopulationData") .group("state", "year") .avg("population") .ascending("populationAvg") .run() .then((results) => { let items = results.items; // see below let numItems = results.length; // 6 let hasNext = results.hasNext(); // false }) .catch((error) => { let errorMsg = error.message; let code = error.code; }); /* Given the sample data above, items is: * [ * { * "_id": {"state": "NY", "year": 2010}, * "populationAvg": 4226500, * "state": "NY", * "year": 2010 * }, { * "_id": {"state": "NY", "year": 2000}, * "populationAvg": 4153500, * "state": "NY", * "year": 2000 * }, { * "_id": {"state": "CA", "year": 2010}, * "populationAvg": 1969000, * "state": "CA", * "year": 2010 * }, { * "_id": {"state": "CA", "year": 2000}, * "populationAvg": 2240000, * "state": "CA", * "year": 2000 * }, { * "_id": {"state": "FL", "year": 2010}, * "populationAvg": 320500, * "state": "FL", * "year": 2010 * }, { * "_id": {"state": "FL", "year": 2000}, * "populationAvg": 278500, * "state": "FL", * "year": 2000 * } * ] */ ``` ---