blob: 664a3fa2be833da4202027b631d775bfadc7ea5b [file] [log] [blame]
var levelSortPriority = {
'fatal' : 1,
'error' : 2,
'warning' : 3,
'info': 4
}
export function vLogSort(item1, item2, key, ascending) {
var first = item1[key];
var second = item2[key];
if (!ascending) {
first = item2[key];
second = item1[key];
}
if (key === 'level') {
first = levelSortPriority[first];
second = levelSortPriority[second];
}
if (typeof first === 'string') {
return first.localeCompare(second);
} else {
return first - second;
}
};