Alphabetical order in drop down

My drop down is in order of created date and I cannot get it to become alphabetical. I tried the ascending (“Names”) but that will only change the creation date from first to last. So my dropdown won’t go alphabetically.

This is the code to get the duplicates out of my dropdown

I figured it out…here is the code

Paste the codes please, not screenshots of them.

This is using two drop downs to search for two different options…couldn’t figure out how to clear just yet so I temp threw in a button to clear results easily. I’m not a coder unfortunately. Here is the code for both dropdowns that I used:

import wixData from ‘wix-data’;

$w.onReady( function () {
// Run a query that returns all the items in the collection
wixData.query(“Patriots”)
// Get the max possible results from the query
.ascending(“Names”)
.limit(1000)
.find()
.then(results => {
// Call the function that creates a list of unique titles
const uniqueNames = getUniqueNames(results.items);

// Call the function that builds the options list from the unique titles
$w(“#dropdown1”).options = buildOptions(uniqueNames);

let options = $w(“#dropdown1”).options;
options.sort( function (a, b) {
let labelA = a.label.toUpperCase();
let labelB = b.label.toUpperCase();
if (labelA < labelB) {
return -1;
}
if (labelA > labelB) {
return 1;
}
return 0;
});
$w(“#dropdown1”).options = options;

    });  

// Builds an array from the “Title” field only from each item in
// the collection and then removes the duplicates
function getUniqueNames(items) {
// Use the map method to create the titlesOnly object containing all the titles from the query results
const NamesOnly = items.map(item => item.title);
// Return an array with a list of unique titles
return [… new Set(NamesOnly)];
}

// Creates an array of objects in the form {label: “label”, value: “value”} from the array of titles
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
return {label:curr, value:curr};
});
}
});

$w.onReady( function () {
// Run a query that returns all the items in the collection
wixData.query(“Patriots”)
// Get the max possible results from the query

    .limit(1000)     
    .find() 
    .then(results => { 

// Call the function that creates a list of unique titles
const uniquekeywords = getUniquekeywords(results.items);

// Call the function that builds the options list from the unique titles
$w(“#dropdown2”).options = buildOptions(uniquekeywords);

let options = $w(“#dropdown2”).options;
options.sort( function (a, b) {
let labelA = a.label.toUpperCase();
let labelB = b.label.toUpperCase();
if (labelA < labelB) {
return -1;
}
if (labelA > labelB) {
return 1;
}
return 0;
});
$w(“#dropdown2”).options = options;

    });  

// Builds an array from the “Title” field only from each item in
// the collection and then removes the duplicates
function getUniquekeywords(items) {
// Use the map method to create the titlesOnly object containing all the titles from the query results
const keywordsOnly = items.map(item => item.keywords);
// Return an array with a list of unique titles
return [… new Set(keywordsOnly)];

} 

// Creates an array of objects in the form {label: “label”, value: “value”} from the array of titles
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
return {label:curr, value:curr};
});
}
});