Skip to content

Commit

Permalink
vmui/logs: fix time sorting #5300
Browse files Browse the repository at this point in the history
  • Loading branch information
Loori-R committed Nov 12, 2023
1 parent bfec8a3 commit f58febb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/vmui/packages/vmui/src/components/Table/helpers.ts
@@ -1,10 +1,17 @@
import { Order } from "../../pages/CardinalityPanel/Table/types";
import dayjs from "dayjs";

const dateColumns = ["date", "timestamp", "time"];

export function descendingComparator<T>(a: T, b: T, orderBy: keyof T) {
if (b[orderBy] < a[orderBy]) {
const valueA = a[orderBy];
const valueB = b[orderBy];
const parsedValueA = dateColumns.includes(`${orderBy}`) ? dayjs(`${valueA}`).unix() : valueA;
const parsedValueB = dateColumns.includes(`${orderBy}`) ? dayjs(`${valueB}`).unix() : valueB;
if (parsedValueB < parsedValueA) {
return -1;
}
if (b[orderBy] > a[orderBy]) {
if (parsedValueB > parsedValueA) {
return 1;
}
return 0;
Expand Down

0 comments on commit f58febb

Please sign in to comment.