From 72651e200956916e612f19c1729f77c180b2b93d Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Wed, 11 Oct 2023 17:11:55 -0500 Subject: [PATCH] fix: service ordering must be alphabetical Closes #780 --- packages/candid/src/idl.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/candid/src/idl.ts b/packages/candid/src/idl.ts index 877523d3d..95a91959b 100644 --- a/packages/candid/src/idl.ts +++ b/packages/candid/src/idl.ts @@ -1481,7 +1481,15 @@ export class ServiceClass extends ConstructType { public readonly _fields: Array<[string, FuncClass]>; constructor(fields: Record) { super(); - this._fields = Object.entries(fields).sort((a, b) => idlLabelToId(a[0]) - idlLabelToId(b[0])); + this._fields = Object.entries(fields).sort((a, b) => { + if (a[0] < b[0]) { + return -1; + } + if (a[0] > b[0]) { + return 1; + } + return 0; + }); } public accept(v: Visitor, d: D): R { return v.visitService(this, d);