我有一个这样的数组:
[1, Stopped]
[2, Waiting]
[3, Finished]
[4, Stopped]
[5, Running]
数字是程序的id,文本是程序的状态。我需要根据下一个顺序对该数组进行排序:
['Error','Halted','Blocked','Finished','Waiting to Start','Waiting','Stopping','Running','Idle','Stopped','Opened','Ready'];
我将它用于除 IE8 之外的所有其他浏览器:
var a = [[1, 'Stopped'],
[2, 'Waiting'],
[3, 'Finished'],
[4, 'Stopped'],
[5, 'Running']];
var order = ['Error','Halted','Blocked','Finished','Waiting to Start','Waiting','Stopping','Running','Idle','Stopped','Opened','Ready'];
a.sort(function (a, b) {
return order.indexOf(a[1]) - order.indexOf(b[1]);
});
它适用于除 IE8 之外的所有不同浏览器。谁能告诉我如何在 IE8 中对其进行排序?