sorting by description in Leaderboard
This commit is contained in:
parent
894e9c9b7c
commit
bab709a7eb
@ -22,6 +22,7 @@ const Leaderboard = (props) => {
|
|||||||
const [pageNr, setPageNr] = React.useState(1);
|
const [pageNr, setPageNr] = React.useState(1);
|
||||||
const [loading, setLoading] = React.useState(true);
|
const [loading, setLoading] = React.useState(true);
|
||||||
const [submitterSorted, setSubmitterSorted] = React.useState(false);
|
const [submitterSorted, setSubmitterSorted] = React.useState(false);
|
||||||
|
const [descriptionSorted, setDescriptionSorted] = React.useState(false);
|
||||||
const [entriesSorted, setEntriesSorted] = React.useState(false);
|
const [entriesSorted, setEntriesSorted] = React.useState(false);
|
||||||
const [whenSorted, setWhenSorted] = React.useState(false);
|
const [whenSorted, setWhenSorted] = React.useState(false);
|
||||||
const [scoresSorted, setScoresSorted] = React.useState([]);
|
const [scoresSorted, setScoresSorted] = React.useState([]);
|
||||||
@ -106,6 +107,27 @@ const Leaderboard = (props) => {
|
|||||||
setSubmitterSorted(true);
|
setSubmitterSorted(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'description':
|
||||||
|
if (descriptionSorted) {
|
||||||
|
newEntries = newEntries.sort((a, b) =>
|
||||||
|
a.description.toLowerCase() < b.description.toLowerCase()
|
||||||
|
? 1
|
||||||
|
: b.description.toLowerCase() < a.description.toLowerCase()
|
||||||
|
? -1
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
setDescriptionSorted(false);
|
||||||
|
} else {
|
||||||
|
newEntries = newEntries.sort((a, b) =>
|
||||||
|
a.description.toLowerCase() > b.description.toLowerCase()
|
||||||
|
? 1
|
||||||
|
: b.description.toLowerCase() > a.description.toLowerCase()
|
||||||
|
? -1
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
setDescriptionSorted(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'entries':
|
case 'entries':
|
||||||
if (entriesSorted) {
|
if (entriesSorted) {
|
||||||
newEntries = newEntries.sort((a, b) => b.times - a.times);
|
newEntries = newEntries.sort((a, b) => b.times - a.times);
|
||||||
|
Loading…
Reference in New Issue
Block a user