Skip to content

Commit

Permalink
[explorer] - sort top validators randomly, ascending on all validator…
Browse files Browse the repository at this point in the history
…s table (MystenLabs#8081)

- adjustments to sort order for validators. random order on home page,
ascending by stake on validators page
  • Loading branch information
mamos-mysten authored Feb 3, 2023
1 parent 24ded7e commit 47dedf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ const validatorsTable = (
) => {
const validators = processValidators(
validatorsData.validators.fields.active_validators
).sort((a, b) =>
a.name.localeCompare(b.name, 'en', {
sensitivity: 'base',
numeric: true,
})
);
).sort((a, b) => (Math.random() > 0.5 ? -1 : 1));

const validatorsItems = limit ? validators.splice(0, limit) : validators;

Expand Down
7 changes: 4 additions & 3 deletions apps/explorer/src/pages/validators/Validators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function validatorsTableData(validators: MoveActiveValidator[], epoch: number) {
? validator.fields.metadata.fields.image_url
: null;
return {
number: index + 1,
name: {
name: validatorName,
logo: validator.fields.metadata.fields.image_url,
Expand All @@ -69,7 +68,9 @@ function validatorsTableData(validators: MoveActiveValidator[], epoch: number) {
accessorKey: 'number',
cell: (props: any) => (
<Text variant="bodySmall/medium" color="steel-dark">
{props.getValue()}
{props.table
.getSortedRowModel()
.flatRows.indexOf(props.row) + 1}
</Text>
),
},
Expand Down Expand Up @@ -209,7 +210,7 @@ function ValidatorPageResult() {
return validatorsTableData(validators, +validatorsData.epoch);
}, [validatorsData]);

const defaultSorting = [{ id: 'stake', desc: true }];
const defaultSorting = [{ id: 'stake', desc: false }];

if (isError || (!isLoading && !validatorsTable?.data.length)) {
return (
Expand Down

0 comments on commit 47dedf7

Please sign in to comment.