So ok, this must be pretty simple, but I just can't get it. Should I create some variables and store parts of code there? Or there's a smarter way? I mean conditions are similar and the logic is similar and I'm not quite sure where to start

```
const comparator = (a: TimeOff, b: TimeOff): number => {
if (order.sortBy === "status" && order.descending) {
  if (a.state === "DECLINED") {
    return -1;
  }
  if (a.state === "APPROVED") {
    return 1;
  }
  return 0;
}
if (order.sortBy === "status" && !order.descending) {
  if (a.state === "DECLINED") {
    return 1;
  }
  if (a.state === "APPROVED") {
    return -1;
  }
  return 0;
}
if (order.sortBy === "dateFrom" && order.descending) {
  if (new Date(a.date_from) < new Date(b.date_from)) {
    return -1;
  }
  if (new Date(a.date_from) > new Date(b.date_from)) {
    return 1;
  }
  return 0;
}
if (order.sortBy === "dateFrom" && !order.descending) {
  if (new Date(a.date_from) < new Date(b.date_from)) {
    return 1;
  }
  if (new Date(a.date_from) > new Date(b.date_from)) {
    return -1;
  }
  return 0;
}}

```