I'm following this link Selecting Multiple Values from a Dropdown List in Google Spreadsheet, it works very well. For Example if i have dropdown with three values like "Red, Black, Green" , and i select "Red & Black" it prints Red & Black perfectly fine, now if i select "Black & Red" it prints respectively. The problem now is if i filter this column in spreadsheet these "Red & Black", "Black & Red" are taken as seperate values which does not make sense because both are same. How can it be done where if i select in any manner it should print alphabattically? any leads? thanks.
Here is the possible solution.
You can add this function a the end of multi-select.gs file:
function sort_contents() {
var range = SpreadsheetApp.getActiveRange();
var values = range.getValues();
var sorted_values = values.map(row => [row[0].split(',').sort().join(',')]);
range.setValues(sorted_values);
}
Add this function into the dialog.html file, after the function function reset() {...}:
function sort_contents() {
google.script.run.withSuccessHandler(x=>{}).sort_contents()
}
And add one more button in the dialog.html:
<input type="button" value="Sort" onclick="sort_contents()" />
After that you will have the button 'Sort' that will sort the contents of selected cell (and cells, you can select several cells) alphabetically. So you will able to sort 'Red, Black' into 'Black, Red' anytime.