I am facing an issue with sorting arrays. I have a custom logic for displaying the array where each object has a 'code' column with values ('A', 'B', or 'C'). The requirement is to sort the records to display 'B' first, then 'A', and finally 'C'.
Link to my code is available on StackBlitz.
Below is the code snippet:
list.sort(function (el1, el2) {
if (el1.codeNumber > el2.codeNumber) {
return 1;
}
if (el1.codeNumber < el2.codeNumber) {
return -1;
}
return 0;
});