#!/usr/bin/env python3 """Standalone synthetic fixture; standard library only. No network, credentials or user paths.""" import json, math, statistics, sys, platform, datetime import re from collections import Counter x=['file1.txt','file10.txt','file2.txt','file02.txt','file001.txt'] def key(s):return [(0,int(t)) if t.isascii() and t.isdigit() else (1,t) for t in re.split(r'([0-9]+)',s)] a=sorted(x);b=sorted(x,key=key);reverse=sorted(list(reversed(x)),key=key) # explicit deterministic tie-break while preserving the identifier string c=sorted(x,key=lambda s:(key(s),s)) # Deliberately wrong: using a display-sort key as a dictionary identity drops names. wrong_by_key={} for name in x:wrong_by_key[tuple(key(name))]=name wrong_survivors=list(wrong_by_key.values()) wrong_lost=sorted(set(x)-set(wrong_survivors)) result={'input':x,'lexical':a,'numericTokensStable':b,'numericTokensReversedInput':reverse,'numericTokensThenExactString':c,'zeroVariantsSameNumericKey':key('file2.txt')==key('file02.txt'),'inputIdentifiersDistinct':len(set(x))==len(x),'identifierStringsKept':all(Counter(v)==Counter(x) for v in [a,b,reverse,c]),'tieBreakInputInvariant':sorted(list(reversed(x)),key=lambda s:(key(s),s))==c,'incorrectDedupBySortKey':{'deliberatelyWrong':True,'inputCount':len(x),'outputCount':len(wrong_survivors),'survivingNames':wrong_survivors,'lostOriginalNames':wrong_lost},'scope':'This comparator handles ASCII digit runs and code-point text ordering, not locale/Unicode collation. Sort keys never rename or merge files. Stable equal-key order depends on input order.'} assert result['identifierStringsKept'] and result['tieBreakInputInvariant'] assert len(wrong_survivors)==3 and wrong_lost==['file1.txt','file2.txt'] assert b==['file1.txt','file001.txt','file2.txt','file02.txt','file10.txt'] and c==['file001.txt','file1.txt','file02.txt','file2.txt','file10.txt'] print(json.dumps({"fixtureCreatedOn":"2026-10-15","executedAt":datetime.datetime.now(datetime.timezone.utc).isoformat(),"synthetic":True,"runtime":platform.python_version(),"result":result},ensure_ascii=False,indent=2))