let values = selectValues;
let names = selectNames;
let priorities = prioritizedHours;
let prefers = preferHrsArray;
let years = workedYearsArray;
let items = values.map((value, index) => {
return {
value: value,
name: names[index],
priority: priorities[index],
prefer: prefers[index],
year: years[index]
}
});
let arrayObject = JSON.stringify(items);
Logger.log('Object array: '+arrayObject);
In this script snippet, I am creating an object from the arrays like names, priorities, etc. Once sorted, the resulting Object looks like this:
[
{"value":1,"name":"Fiona","prefer":30,"year":6},
{"value":1,"name":"Martin","prefer":40,"year":7},
{"value":2,"name":"Adam","prefer":0,"year":20},
{"value":2,"name":"Steve","prefer":100,"year":5}
]
Now that the sorting is complete, I need to revert back to separate arrays as they were in the original Object. The format of these arrays should be like:
value = [1,1,2,2],
name = ['Fiona', 'Martin','Adam', 'Steve'],
prefer = [30,40,0,100],
year = [6,7,20,5]
Your assistance with this matter is greatly appreciated.