我的范围有以下值“延迟”、“是”、“否”。这些值需要按顺序排序。
没有其他列的空间,有1,2,3值,工作表函数也不是一个选项。仅仅用Google脚本就能做到这一点吗?
扩展问题:有两个额外的列包含文本值,需要进行升序排序。目前我是这样做的:
rng.sort([{column: 1, CUSTOM_SORT_NEEDED}, {column: 2, ascending: true}, {column: 3, ascending: true}, ]);
发布于 2016-05-13 10:51:30
所以,这是对我有用的,我用了一本字典。不确定是最好的,还是最好的,但效果好。
function compare(a,b) {
var crits = {"Yes":1,"No":2,"Postpone":3};
var col =1;
var result = 0;
if (crits[a[col]] > crits[b[col]]) {result = 1}
else if (crits[a[col]] == crits[b[col]]) {result = 0}
else {result = -1}
return result;
}https://stackoverflow.com/questions/37205450
复制相似问题