I have a criticality array and I want to sort by criticality, something like this:
let criticalityTypes = ['CRITICALITY_LOW', 'CRITICALITY_HIGH', 'CRITICALITY_MEDIUM'];
I get this order randomly, sometimes ** CRITICALITY_LOW ** comes in position 1 of the matrix ie either position 2, or 'CRITICALITY_MEDIUM' in 0 position,
What I want to do is order in the following order, regardless of the order that comes to me, sometimes I have just one criticality, or two:
['CRITICALITY_HIGH', 'CRITICALITY_MEDIUM', 'CRITICALITY_LOW'];
I tried to use sort function to order what I've done so far is this:
return criticalityTypes.sort((a, b) => {
if (a < b) return -1;
if (a > b) return 1;
});
But without success, any help?