Explicitly sort the chains by their content, for stable sort.
Chris Pressey
4 years ago
6 | 6 | * Split TODO off into own file. |
7 | 7 | * `sixtypical` no longer writes the compiled binary to standard |
8 | 8 | output. The `--output` command-line argument should be given. |
9 | * Many tests pass when `sixtypical` is run with Python 3. | |
9 | * All tests pass when `sixtypical` is run under Python 3.5.2. | |
10 | 10 | |
11 | 11 | 0.16 |
12 | 12 | ---- |
42 | 42 | |
43 | 43 | while pending_routines: |
44 | 44 | chains = [self.find_chain(k, pending_routines) for k in pending_routines.keys()] |
45 | chains.sort(key=len, reverse=True) | |
45 | chains.sort(key=lambda x: (len(x), str(x)), reverse=True) | |
46 | 46 | c = chains[0] |
47 | 47 | roster.append(c) |
48 | 48 | for k in c: |
173 | 173 | = "main" |
174 | 174 | = ], |
175 | 175 | = [ |
176 | = "bar", | |
177 | = "foo" | |
176 | = "foo", | |
177 | = "bar" | |
178 | 178 | = ] |
179 | 179 | = ] |
180 | 180 | |
205 | 205 | = "main" |
206 | 206 | = ], |
207 | 207 | = [ |
208 | = "foo" | |
209 | = ], | |
210 | = [ | |
208 | 211 | = "bar" |
209 | = ], | |
210 | = [ | |
211 | = "foo" | |
212 | 212 | = ] |
213 | 213 | = ] |
214 | 214 | |
270 | 270 | = "main" |
271 | 271 | = ], |
272 | 272 | = [ |
273 | = "foo" | |
274 | = ], | |
275 | = [ | |
273 | 276 | = "bar" |
274 | = ], | |
275 | = [ | |
276 | = "foo" | |
277 | 277 | = ] |
278 | 278 | = ] |
279 | 279 | |
415 | 415 | | { |
416 | 416 | | } |
417 | 417 | = $080D RTS |
418 | = $080E LDA #$FF | |
419 | = $0810 RTS | |
420 | = $0811 LDA #$00 | |
421 | = $0813 BNE $081D | |
422 | = $0815 LDA #$01 | |
423 | = $0817 JMP $080E | |
424 | = $081A JMP $0822 | |
425 | = $081D LDA #$02 | |
426 | = $081F JMP $080D | |
418 | = $080E LDA #$00 | |
419 | = $0810 BNE $081A | |
420 | = $0812 LDA #$01 | |
421 | = $0814 JMP $081F | |
422 | = $0817 JMP $081F | |
423 | = $081A LDA #$02 | |
424 | = $081C JMP $080D | |
425 | = $081F LDA #$FF | |
426 | = $0821 RTS |