Skip to content

Commit

Permalink
Simplify sort func
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Jan 31, 2025
1 parent b037b71 commit a6071be
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/helpers/processContractStorageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ export const processContractStorageData = <T extends AnyObject>({

// Sort
if (sortById) {
if (["asc", "desc"].includes(sortByDir)) {
// Asc
// Asc
if (sortByDir === "asc") {
sortedData = sortedData.sort((a: any, b: any) =>
a[sortById] > b[sortById] ? 1 : -1,
);
}

// Desc
if (sortByDir === "desc") {
sortedData = sortedData.reverse();
}
// Desc
if (sortByDir === "desc") {
sortedData = sortedData.sort((a: any, b: any) =>
a[sortById] > b[sortById] ? -1 : 1,
);
}
}

Expand Down

0 comments on commit a6071be

Please sign in to comment.