From 95faa7b35f2e3e34b575190c7928da1d359fe090 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Thu, 22 Jan 2026 16:46:11 +0800 Subject: [PATCH] fix: make attrValues' order consistent --- nix-js/runtime-ts/src/builtins/attrs.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nix-js/runtime-ts/src/builtins/attrs.ts b/nix-js/runtime-ts/src/builtins/attrs.ts index 88fe3fd..8883342 100644 --- a/nix-js/runtime-ts/src/builtins/attrs.ts +++ b/nix-js/runtime-ts/src/builtins/attrs.ts @@ -8,7 +8,18 @@ import { createThunk } from "../thunk"; export const attrNames = (set: NixValue): string[] => Object.keys(forceAttrs(set)).sort(); -export const attrValues = (set: NixValue): NixValue[] => Object.values(forceAttrs(set)); +export const attrValues = (set: NixValue): NixValue[] => + Object.entries(forceAttrs(set)) + .sort(([a], [b]) => { + if (a < b) { + return -1; + } else if (a === b) { + return 0; + } else { + return 1; + } + }) + .map(([_, val]) => val); export const getAttr = (s: NixValue) =>