hygiene = ($options, skipSort = false) => {
	// Process __removeOnDeselect
	$options = $options.filter((o) => !(o.__removeOnDeselect && !o.selected));

	// Uniqueify
	const knownValues = new Set();
	$options = $options.reduce((a, c) => {
		if (!knownValues.has(optStr(c))) {
			knownValues.add(optStr(c));
			a.push(c);
		}
		return a;
	}, /** @type {DropdownOption[]} */ ([]));
	if (skipSort) {
		return $options;
	}

	// Sort
	$options = $options.sort((a, b) => {
		// Selected options go to the top
		if (a.selected && !b.selected) return -1;
		if (b.selected && !a.selected) return 1;

		// Auto options go to the bottom
		if (a.__auto && !b.__auto) return 1;
		if (b.__auto && !a.__auto) return -1;

		// Sort by index
		if (a.idx !== b.idx) {
			return (a.idx ?? 0) - (b.idx ?? 0);
		}

		// Sort by label
		// Nulls go to the bottom
		if (a.label === null && b.label !== null) return 1;
		if (b.label === null && a.label !== null) return -1;
		if (a.label === null && b.label === null) return 0;
		// Compare numbers
		if (typeof a.label === 'number' && typeof b.label === 'number' && a.label !== b.label) {
			return a.label - b.label;
		}
		// Compare strings
		if (
			typeof a.label !== 'undefined' &&
			a.label !== null &&
			typeof b.label !== 'undefined' &&
			b.label !== null
		) {
			const labelDiff = a.label.toString().localeCompare(b.label.toString());
			if (labelDiff !== 0) return labelDiff;
		}

		// If labels are the same, sort by value
		if (
			typeof a.value !== 'undefined' &&
			a.value !== null &&
			typeof b.value !== 'undefined' &&
			b.value !== null
		) {
			const valueDiff = a.value.toString().localeCompare(b.value.toString());
			if (valueDiff !== 0) return valueDiff;
		}

		return 0;
	});

	return $options;
}
@param {DropdownOption[]} $options
@param {boolean} [skipSort=false]
@returns