var list = [
{ "WARNING_LABLE": "1:3", "WARNING_TYPE_CUST_NUMBER": "400" },
{ "WARNING_LABLE": "2:1", "WARNING_TYPE_CUST_NUMBER": "400" },
{ "WARNING_LABLE": "2:3", "WARNING_TYPE_CUST_NUMBER": "400" },
{ "WARNING_LABLE": "1:1", "WARNING_TYPE_CUST_NUMBER": "400" },
{ "WARNING_LABLE": "1:2", "WARNING_TYPE_CUST_NUMBER": "400" },
{ "WARNING_LABLE": "3:2", "WARNING_TYPE_CUST_NUMBER": "400" }
]
console.log(generateNewData(list))
function generateNewData(list) {
var one = [];
var two = [];
var three = [];
list.forEach(function (item, index, self) {
var warnType = item.WARNING_LABLE.substring(0, 1)
if (warnType == 1) {
one.push(item);
} else if (warnType == 2) {
two.push(item);
} else if (warnType == 3) {
three.push(item);
}
})
one.sort(function (a, b) { return a.WARNING_LABLE.substring(2) - b.WARNING_LABLE.substring(2) })
two.sort(function (a, b) { return a.WARNING_LABLE.substring(2) - b.WARNING_LABLE.substring(2) })
three.sort(function (a, b) { return a.WARNING_LABLE.substring(2) - b.WARNING_LABLE.substring(2) })
return [one, two, three]
}
console