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);