Skip to content

Commit

Permalink
fix: improve sorting of proof files by numeric value (#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordshashank authored Feb 13, 2025
1 parent 4856de6 commit bc55826
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/contracts/tasks/runner/submitOnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ async function readProofs({ files, folder, type }: IReadProofsArgs): Promise<Pro
return Promise.all(
files
.filter((f) => f.startsWith(`${type}_`) && f.endsWith(".json"))
.sort()
.sort((a, b) => {
const numA = parseInt(a.match(/\d+/)?.[0] ?? "0", 10);
const numB = parseInt(b.match(/\d+/)?.[0] ?? "0", 10);
return numA - numB;
})
.map(async (file) =>
fs.promises.readFile(`${folder}/${file}`, "utf8").then((result) => JSON.parse(result) as Proof),
),
Expand Down

0 comments on commit bc55826

Please sign in to comment.