From 4c333606494a962d4bd79c6a79b20695517fbff7 Mon Sep 17 00:00:00 2001 From: Martyn Ranyard Date: Sat, 1 Aug 2020 12:57:02 +0200 Subject: [PATCH] Ensure if you're sorting by last dueted with date, solo performances are always at the end Signed-off-by: Martyn Ranyard --- build/react-frontend/src/Components/DuetData/DuetData.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/react-frontend/src/Components/DuetData/DuetData.js b/build/react-frontend/src/Components/DuetData/DuetData.js index 5b829de..6e5d9ff 100644 --- a/build/react-frontend/src/Components/DuetData/DuetData.js +++ b/build/react-frontend/src/Components/DuetData/DuetData.js @@ -15,7 +15,10 @@ const headCells = [ { id: 'displayLastDuetDate', numeric: false, disablePadding: false, label: 'Last Dueted with Singer' }, ]; -function descendingComparator(a, b, orderBy) { +function descendingComparator(a, b, orderBy, order) { + if ((b[orderBy] === "Solo performance") && (a[orderBy] !== "Solo performance")) { + return order === 'desc' ? -1 : 1 + } if (orderBy === "displayPublishDate") { orderBy = "publishDate" } @@ -46,8 +49,8 @@ function stableSort(array, comparator) { function getComparator(order, orderBy) { return order === 'desc' - ? (a, b) => descendingComparator(a, b, orderBy) - : (a, b) => -descendingComparator(a, b, orderBy); + ? (a, b) => descendingComparator(a, b, orderBy, order) + : (a, b) => -descendingComparator(a, b, orderBy, order); } function EnhancedTableHead(props) {