I want to sort an array by an enumeration, then by a number then by date. When I do it with enumeration and number it seems to work fine however when I include the date at the end it messes everything.
Here's my code:
enum myType {
high,
medium,
low
}
myArray.sort((a, b) =>
myType[a.type] - myType[b.type] ||
a.classification - b.classification ||
new Date(a.time) > new Date(b.time)
? -1
: 1
);
However this seems to sort the opposite meaning it sorts by type in the opposite order where low first and high last. How do we go about this?
Update: Date will get passed as this: 2017-07-02T14:59:55.711Z