diff --git a/optuna_dashboard/static/components/DataGrid.tsx b/optuna_dashboard/static/components/DataGrid.tsx index f62d76e7..e0c44f63 100644 --- a/optuna_dashboard/static/components/DataGrid.tsx +++ b/optuna_dashboard/static/components/DataGrid.tsx @@ -72,7 +72,7 @@ function DataGrid(props: { const { columns, rows, keyField, dense, collapseBody } = props let { initialRowsPerPage, rowsPerPageOption } = props const [order, setOrder] = React.useState("asc") - const [orderBy, setOrderBy] = React.useState(0) // index of columns + const [orderBy, setOrderBy] = React.useState(0) // index of columns const [page, setPage] = React.useState(0) const [filters, setFilters] = React.useState[]>([]) @@ -133,7 +133,12 @@ function DataGrid(props: { setOrderBy(columnId) } const lessFunc = columns[orderBy].less - const sortedRows = stableSort(filteredRows, getComparator(order, columns, orderBy), order, lessFunc) + const sortedRows = stableSort( + filteredRows, + getComparator(order, columns, orderBy), + order, + lessFunc + ) const currentPageRows = rowsPerPage > 0 ? sortedRows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) @@ -311,10 +316,10 @@ function getComparator( } function descendingComparator( - a: T, - b: T, - columns: DataGridColumn[], - orderBy: number + a: T, + b: T, + columns: DataGridColumn[], + orderBy: number ): number { const field = columns[orderBy].field if (b[field] < a[field]) { @@ -327,10 +332,10 @@ function descendingComparator( } function stableSort( - array: T[], - comparator: (a: T, b: T) => number, - order: Order, - less?: (i: number, j: number) => number + array: T[], + comparator: (a: T, b: T) => number, + order: Order, + less?: (i: number, j: number) => number ) { const stabilizedThis = array.map((el, index) => [el, index] as [T, number]) stabilizedThis.sort((a, b) => { diff --git a/optuna_dashboard/static/components/StudyDetail.tsx b/optuna_dashboard/static/components/StudyDetail.tsx index 661c02c9..6847be4f 100644 --- a/optuna_dashboard/static/components/StudyDetail.tsx +++ b/optuna_dashboard/static/components/StudyDetail.tsx @@ -245,14 +245,18 @@ const TrialTable: FC<{ studyDetail: StudyDetail | null }> = ({ label: `Objective ${objectiveId}`, sortable: true, less: (i, j): number => { - if (trials[i].values?.[objectiveId] === trials[j].values?.[objectiveId]) { + if ( + trials[i].values?.[objectiveId] === trials[j].values?.[objectiveId] + ) { return 0 } else if (trials[i].values === undefined) { return -1 } else if (trials[j].values === undefined) { return 1 } - return trials[i].values![objectiveId] < trials[j].values![objectiveId] ? 1 : -1 + return trials[i].values![objectiveId] < trials[j].values![objectiveId] + ? 1 + : -1 }, toCellValue: (i) => trials[i].values?.[objectiveId] || null, }))