summarylogtreecommitdiffstats
path: root/sagemath-ipython7.patch
blob: 5d6e817348f95f2a1eca07b343dc6af81fa17f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
index d1e8bf7388..557fbb2942 100644
--- a/src/sage/doctest/forker.py
+++ b/src/sage/doctest/forker.py
@@ -183,15 +183,6 @@ def init_sage():
     from sage.repl.rich_output.backend_doctest import BackendDoctest
     dm.switch_backend(BackendDoctest())
 
-    # IPython's pretty printer sorts the repr of dicts by their keys by default
-    # (or their keys' str() if they are not otherwise orderable).  However, it
-    # disables this for CPython 3.6+ opting to instead display dicts' "natural"
-    # insertion order, which is preserved in those versions).  This makes for
-    # inconsistent results with Python 2 tests that return dicts, so here we
-    # force the Python 2 style dict printing
-    import IPython.lib.pretty
-    IPython.lib.pretty.DICT_IS_ORDERED = False
-
     # Switch on extra debugging
     from sage.structure.debug_options import debug
     debug.refine_category_hash_check = True
diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
index 4054bd5d9a..236b861c8a 100644
--- a/src/sage/algebras/cluster_algebra.py
+++ b/src/sage/algebras/cluster_algebra.py
@@ -183,7 +183,7 @@ g-vectors and F-polynomials can be computed from elements of ``A`` only if
     sage: (t+s).is_homogeneous()
     False
     sage: (t+s).homogeneous_components()
-    {(-1, 1): (x1 + y0)/x0, (0, -1): (x0*y1 + 1)/x1}
+    {(0, -1): (x0*y1 + 1)/x1, (-1, 1): (x1 + y0)/x0}
 
 Each cluster algebra is endowed with a reference to a current seed;
 it could be useful to assign a name to it::
@@ -559,7 +559,7 @@ class PrincipalClusterAlgebraElement(ClusterAlgebraElement):
             sage: A = ClusterAlgebra(['B', 2], principal_coefficients=True)
             sage: x = A.cluster_variable((1, 0)) + A.cluster_variable((0, 1))
             sage: x.homogeneous_components()
-            {(0, 1): x1, (1, 0): x0}
+            {(1, 0): x0, (0, 1): x1}
         """
         deg_matrix = block_matrix([[identity_matrix(self.parent().rank()),
                                     -self.parent().b_matrix()]])
diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
index d519d37b61..5ffc82d27f 100644
--- a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
+++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
@@ -662,7 +662,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
             sage: b.monomial_coefficients()        # We set b._monomial_coefficients
             {0: 1, 1: 2}
             sage: (a + b).monomial_coefficients()  # This is now computed from a and b
-            {0: 1, 1: 4, 2: 4}
+            {1: 4, 2: 4, 0: 1}
         """
         cdef LieSubalgebraElementWrapper ret, other = <LieSubalgebraElementWrapper> right
         ret = type(self)(self._parent, self.value + other.value)
@@ -688,7 +688,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
             sage: b.monomial_coefficients()        # We set b._monomial_coefficients
             {0: 1, 1: 2}
             sage: (a - b).monomial_coefficients()  # This is now computed from a and b
-            {0: -1, 2: 4}
+            {2: 4, 0: -1}
         """
         cdef LieSubalgebraElementWrapper ret, other = <LieSubalgebraElementWrapper> right
         ret = type(self)(self._parent, self.value - other.value)
@@ -1046,9 +1046,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
             sage: L = lie_algebras.Affine(QQ, ['A',1,1])
             sage: x = L.an_element()
             sage: x.t_dict()
-            {-1: E[alpha[1]],
-             0: E[alpha[1]] + h1 + E[-alpha[1]],
-             1: E[-alpha[1]]}
+            {0: E[alpha[1]] + h1 + E[-alpha[1]], 1: E[-alpha[1]], -1: E[alpha[1]]}
         """
         return self._t_dict.copy()
 
diff --git a/src/sage/algebras/quantum_groups/representations.py b/src/sage/algebras/quantum_groups/representations.py
index e75cafc003..194eb7b1a3 100644
--- a/src/sage/algebras/quantum_groups/representations.py
+++ b/src/sage/algebras/quantum_groups/representations.py
@@ -343,8 +343,7 @@ class AdjointRepresentation(CyclicRepresentation):
             sage: R = ZZ['q'].fraction_field()
             sage: V = AdjointRepresentation(R, K)
             sage: V._zero_elts
-            {0: [], 1: [[2], [-2]], 2: [[3], [-3]],
-             3: [[4], [-4]], 4: [[-4], [4]]}
+            {0: [], 4: [[-4], [4]], 3: [[4], [-4]], 2: [[3], [-3]], 1: [[2], [-2]]}
         """
         C = self.basis().keys()
         ret = {}
diff --git a/src/sage/algebras/weyl_algebra.py b/src/sage/algebras/weyl_algebra.py
index 95e12d460b..26a238725c 100644
--- a/src/sage/algebras/weyl_algebra.py
+++ b/src/sage/algebras/weyl_algebra.py
@@ -590,7 +590,7 @@ class DifferentialWeylAlgebraElement(AlgebraElement):
             sage: x
             t^3*dt^3 + t^4*dt^2 + 9*t^2*dt^2 + 8*t^3*dt + 18*t*dt + 12*t^2 + 6
             sage: x.factor_differentials()
-            {(0,): 12*t^2 + 6, (1,): 8*t^3 + 18*t, (2,): t^4 + 9*t^2, (3,): t^3}
+            {(3,): t^3, (2,): t^4 + 9*t^2, (1,): 8*t^3 + 18*t, (0,): 12*t^2 + 6}
             sage: D.zero().factor_differentials()
             {}
 
@@ -602,17 +602,17 @@ class DifferentialWeylAlgebraElement(AlgebraElement):
             x^3*dy^3 + x*y*z*dx*dy*dz + y^3*dx^3 + x^3*dx^3 - x*z*dx^3 + y*z*dy*dz
              + x*z*dx*dz + x*y*dx*dy + 9*x^2*dx^2 + z*dz + y*dy + 19*x*dx + 7
             sage: elt.factor_differentials()
-            {(0, 0, 0): 7,
-             (0, 0, 1): z,
-             (0, 1, 0): y,
+            {(0, 3, 0): x^3,
+             (1, 1, 1): x*y*z,
+             (3, 0, 0): x^3 + y^3 - x*z,
              (0, 1, 1): y*z,
-             (0, 3, 0): x^3,
-             (1, 0, 0): 19*x,
              (1, 0, 1): x*z,
              (1, 1, 0): x*y,
-             (1, 1, 1): x*y*z,
              (2, 0, 0): 9*x^2,
-             (3, 0, 0): x^3 + y^3 - x*z}
+             (0, 0, 1): z,
+             (0, 1, 0): y,
+             (1, 0, 0): 19*x,
+             (0, 0, 0): 7}
         """
         ret = {}
         DW = self.parent()
diff --git a/src/sage/all.py b/src/sage/all.py
index 1e36169b1b..e18bd9a587 100644
--- a/src/sage/all.py
+++ b/src/sage/all.py
@@ -19,7 +19,7 @@ We exclude the dependencies and check to see that there are no others
 except for the known bad apples::
 
     sage: allowed = [
-    ....:     'IPython', 'prompt_toolkit',     # sage dependencies
+    ....:     'IPython', 'prompt_toolkit', 'jedi',   # sage dependencies
     ....:     'threading', 'multiprocessing',  # doctest dependencies
     ....:     '__main__', 'sage.doctest',      # doctesting
     ....:     'signal', 'enum',                # may appear in Python 3
diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
index ff6557068b..1cf0bb41a0 100644
--- a/src/sage/categories/category.py
+++ b/src/sage/categories/category.py
@@ -1771,8 +1771,8 @@ class Category(UniqueRepresentation, SageObject):
             {'element': {'optional': ['_add_', '_mul_'], 'required': ['__nonzero__']},
              'parent': {'optional': ['algebra_generators'], 'required': ['__contains__']}}
             sage: Algebras(QQ).required_methods() # py3
-            {'element': {'optional': ['_add_', '_mul_'], 'required': ['__bool__']},
-             'parent': {'optional': ['algebra_generators'], 'required': ['__contains__']}}
+            {'parent': {'required': ['__contains__'], 'optional': ['algebra_generators']},
+             'element': {'required': ['__bool__'], 'optional': ['_add_', '_mul_']}}
         """
         return { "parent"  : abstract_methods_of_class(self.parent_class),
                  "element" : abstract_methods_of_class(self.element_class) }
diff --git a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
index edb8a5ffbc..fd842316c6 100644
--- a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
+++ b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
@@ -86,12 +86,13 @@ class ComplexReflectionOrGeneralizedCoxeterGroups(Category_singleton):
         [Category of finitely generated enumerated groups]
 
         sage: C.required_methods()
-        {'element': {'optional': ['reflection_length'],
-                     'required': []},
-          'parent': {'optional': ['distinguished_reflection', 'hyperplane_index_set',
-                                  'irreducible_components',
-                                  'reflection', 'reflection_index_set'],
-                    'required':  ['__contains__', 'index_set']}}
+        {'parent': {'required': ['__contains__', 'index_set'],
+          'optional': ['distinguished_reflection',
+           'hyperplane_index_set',
+           'irreducible_components',
+           'reflection',
+           'reflection_index_set']},
+         'element': {'required': [], 'optional': ['reflection_length']}}
 
     TESTS::
 
diff --git a/src/sage/categories/crystals.py b/src/sage/categories/crystals.py
index f19a7d963e..e6536f5eae 100644
--- a/src/sage/categories/crystals.py
+++ b/src/sage/categories/crystals.py
@@ -76,7 +76,7 @@ class Crystals(Category_singleton):
 
         sage: from sage.misc.abstract_method import abstract_methods_of_class
         sage: abstract_methods_of_class(Crystals().element_class)
-        {'optional': [], 'required': ['e', 'epsilon', 'f', 'phi', 'weight']}
+        {'required': ['e', 'epsilon', 'f', 'phi', 'weight'], 'optional': []}
 
     TESTS::
 
diff --git a/src/sage/categories/finite_dimensional_algebras_with_basis.py b/src/sage/categories/finite_dimensional_algebras_with_basis.py
index 7b14ee25c1..f4a34aace0 100644
--- a/src/sage/categories/finite_dimensional_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_algebras_with_basis.py
@@ -1276,9 +1276,9 @@ class FiniteDimensionalAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
 
                     sage: S = SymmetricGroupAlgebra(QQ, 3)
                     sage: dict(S.cells())
-                    {[1, 1, 1]: Standard tableaux of shape [1, 1, 1],
+                    {[3]: Standard tableaux of shape [3],
                      [2, 1]: Standard tableaux of shape [2, 1],
-                     [3]: Standard tableaux of shape [3]}
+                     [1, 1, 1]: Standard tableaux of shape [1, 1, 1]}
                 """
                 from sage.sets.family import Family
                 return Family(self.cell_poset(), self.cell_module_indices)
diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx
index f4e8ab21be..932299d749 100644
--- a/src/sage/categories/map.pyx
+++ b/src/sage/categories/map.pyx
@@ -444,8 +444,8 @@ cdef class Map(Element):
             sage: from sage.categories.map import Map
             sage: f = Map(Hom(QQ, ZZ, Rings()))
             sage: f._extra_slots_test()
-            {'_codomain': Integer Ring,
-             '_domain': Rational Field,
+            {'_domain': Rational Field,
+             '_codomain': Integer Ring,
              '_is_coercion': False,
              '_repr_type_str': None}
         """
diff --git a/src/sage/categories/morphism.pyx b/src/sage/categories/morphism.pyx
index 391422bdf5..ef824b9777 100644
--- a/src/sage/categories/morphism.pyx
+++ b/src/sage/categories/morphism.pyx
@@ -601,11 +601,11 @@ cdef class SetMorphism(Morphism):
 
             sage: f = sage.categories.morphism.SetMorphism(Hom(ZZ,ZZ, Sets()), operator.__abs__)
             sage: f._extra_slots_test()
-            {'_codomain': Integer Ring,
-             '_domain': Integer Ring,
-             '_function': <built-in function ...abs...>,
+            {'_domain': Integer Ring,
+             '_codomain': Integer Ring,
              '_is_coercion': False,
-             '_repr_type_str': None}
+             '_repr_type_str': None,
+             '_function': <built-in function abs>}
         """
         slots = Map._extra_slots(self)
         slots['_function'] = self._function
diff --git a/src/sage/categories/primer.py b/src/sage/categories/primer.py
index 5eba042a44..02810a5f5f 100644
--- a/src/sage/categories/primer.py
+++ b/src/sage/categories/primer.py
@@ -764,8 +764,8 @@ operations. In particular a list of mandatory and optional methods to
 be implemented can be found by introspection with::
 
     sage: Groups().required_methods()
-    {'element': {'optional': ['_mul_'], 'required': []},
-     'parent': {'optional': [], 'required': ['__contains__']}}
+    {'parent': {'required': ['__contains__'], 'optional': []},
+     'element': {'required': [], 'optional': ['_mul_']}}
 
 Documentation about those methods can be obtained with::
 
@@ -988,9 +988,9 @@ A (not yet complete) list of mandatory and optional methods to be
 implemented can be found by introspection with::
 
     sage: FiniteSemigroups().required_methods()
-    {'element': {'optional': ['_mul_'], 'required': []},
-     'parent': {'optional': ['semigroup_generators'],
-      'required': ['__contains__']}}
+    {'parent': {'required': ['__contains__'],
+      'optional': ['semigroup_generators']},
+     'element': {'required': [], 'optional': ['_mul_']}}
 
 ``product`` does not appear in the list because a default implementation
 is provided in term of the method ``_mul_`` on elements. Of course, at
diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py
index 0fe756e525..7ba5048a7c 100644
--- a/src/sage/categories/pushout.py
+++ b/src/sage/categories/pushout.py
@@ -2387,7 +2387,7 @@ class CompletionFunctor(ConstructionFunctor):
             sage: F2
             Completion[+Infinity, prec=53]
             sage: F2.extras
-            {'rnd': 0, 'sci_not': False, 'type': 'MPFR'}
+            {'type': 'MPFR', 'sci_not': False, 'rnd': 0}
         """
         Functor.__init__(self, Rings(), Rings())
         self.p = p
diff --git a/src/sage/categories/regular_supercrystals.py b/src/sage/categories/regular_supercrystals.py
index cccb2e94fa..d42383d9db 100644
--- a/src/sage/categories/regular_supercrystals.py
+++ b/src/sage/categories/regular_supercrystals.py
@@ -55,7 +55,7 @@ class RegularSuperCrystals(Category_singleton):
         sage: from sage.misc.abstract_method import abstract_methods_of_class
         sage: from sage.categories.regular_supercrystals import RegularSuperCrystals
         sage: abstract_methods_of_class(RegularSuperCrystals().element_class)
-        {'optional': [], 'required': ['e', 'f', 'weight']}
+        {'required': ['e', 'f', 'weight'], 'optional': []}
 
     TESTS::
 
diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
index 57ef7fb896..db347b9e2f 100644
--- a/src/sage/coding/linear_code.py
+++ b/src/sage/coding/linear_code.py
@@ -3847,22 +3847,22 @@ class LinearCodeSyndromeDecoder(Decoder):
             sage: D = codes.decoders.LinearCodeSyndromeDecoder(C, maximum_error_weight = 1)
             sage: D._build_lookup_table()
             {(0, 0, 0, 0): (0, 0, 0, 0, 0, 0, 0, 0),
-             (0, 0, 0, 1): (0, 0, 0, 0, 1, 0, 0, 0),
-             (0, 0, 0, 2): (0, 0, 0, 0, 2, 0, 0, 0),
-             (0, 0, 1, 0): (0, 0, 1, 0, 0, 0, 0, 0),
-             (0, 0, 1, 2): (0, 0, 0, 0, 0, 0, 0, 1),
-             (0, 0, 2, 0): (0, 0, 2, 0, 0, 0, 0, 0),
-             (0, 0, 2, 1): (0, 0, 0, 0, 0, 0, 0, 2),
+             (1, 0, 0, 0): (1, 0, 0, 0, 0, 0, 0, 0),
+             (2, 0, 0, 0): (2, 0, 0, 0, 0, 0, 0, 0),
              (0, 1, 0, 0): (0, 1, 0, 0, 0, 0, 0, 0),
-             (0, 1, 1, 2): (0, 0, 0, 0, 0, 0, 2, 0),
              (0, 2, 0, 0): (0, 2, 0, 0, 0, 0, 0, 0),
-             (0, 2, 2, 1): (0, 0, 0, 0, 0, 0, 1, 0),
-             (1, 0, 0, 0): (1, 0, 0, 0, 0, 0, 0, 0),
-             (1, 2, 0, 2): (0, 0, 0, 0, 0, 1, 0, 0),
+             (0, 0, 1, 0): (0, 0, 1, 0, 0, 0, 0, 0),
+             (0, 0, 2, 0): (0, 0, 2, 0, 0, 0, 0, 0),
              (1, 2, 2, 0): (0, 0, 0, 1, 0, 0, 0, 0),
-             (2, 0, 0, 0): (2, 0, 0, 0, 0, 0, 0, 0),
+             (2, 1, 1, 0): (0, 0, 0, 2, 0, 0, 0, 0),
+             (0, 0, 0, 1): (0, 0, 0, 0, 1, 0, 0, 0),
+             (0, 0, 0, 2): (0, 0, 0, 0, 2, 0, 0, 0),
+             (1, 2, 0, 2): (0, 0, 0, 0, 0, 1, 0, 0),
              (2, 1, 0, 1): (0, 0, 0, 0, 0, 2, 0, 0),
-             (2, 1, 1, 0): (0, 0, 0, 2, 0, 0, 0, 0)}
+             (0, 2, 2, 1): (0, 0, 0, 0, 0, 0, 1, 0),
+             (0, 1, 1, 2): (0, 0, 0, 0, 0, 0, 2, 0),
+             (0, 0, 1, 2): (0, 0, 0, 0, 0, 0, 0, 1),
+             (0, 0, 2, 1): (0, 0, 0, 0, 0, 0, 0, 2)}
 
         TESTS:
 
@@ -3876,11 +3876,11 @@ class LinearCodeSyndromeDecoder(Decoder):
             sage: D = codes.decoders.LinearCodeSyndromeDecoder(C)
             sage: D.syndrome_table()
              {(0, 0): (0, 0, 0),
-              (0, 1): (0, 1, 0),
-              (0, 2): (0, 2, 0),
-              (0, a): (0, a, 0),
+              (1, 0): (1, 0, 0),
+              (2, 0): (2, 0, 0),
+              (a, 0): (a, 0, 0),
              ...
-              (2*a + 2, 2*a): (0, 0, 2),
+              (2*a + 2, a + 2): (2*a + 2, a + 2, 0),
               (2*a + 2, 2*a + 1): (2*a + 2, 2*a + 1, 0),
               (2*a + 2, 2*a + 2): (2*a + 2, 2*a + 2, 0)}
         """
@@ -4035,12 +4035,12 @@ class LinearCodeSyndromeDecoder(Decoder):
             sage: D = codes.decoders.LinearCodeSyndromeDecoder(C)
             sage: D.syndrome_table()
             {(0, 0, 0): (0, 0, 0, 0, 0, 0, 0),
-             (0, 0, 1): (0, 0, 0, 1, 0, 0, 0),
-             (0, 1, 0): (0, 1, 0, 0, 0, 0, 0),
-             (0, 1, 1): (0, 0, 0, 0, 0, 1, 0),
              (1, 0, 0): (1, 0, 0, 0, 0, 0, 0),
-             (1, 0, 1): (0, 0, 0, 0, 1, 0, 0),
+             (0, 1, 0): (0, 1, 0, 0, 0, 0, 0),
              (1, 1, 0): (0, 0, 1, 0, 0, 0, 0),
+             (0, 0, 1): (0, 0, 0, 1, 0, 0, 0),
+             (1, 0, 1): (0, 0, 0, 0, 1, 0, 0),
+             (0, 1, 1): (0, 0, 0, 0, 0, 1, 0),
              (1, 1, 1): (0, 0, 0, 0, 0, 0, 1)}
         """
         return self._lookup_table
diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
index d5c469050a..c0720a828e 100644
--- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
+++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
@@ -2735,119 +2735,119 @@ class ClusterSeed(SageObject):
             sage: B = [[0, 4, 0, -1],[-4,0, 3, 0],[0, -3, 0, 1],[1, 0, -1, 0]]
             sage: S = ClusterSeed(matrix(B)); S.mutate([2,3,1,2,1,3,0,2])
             sage: S.mutation_analysis()
-            {0: {'d_matrix': [ 0  0  1  0]
-              [ 0 -1  0  0]
-              [ 0  0  0 -1]
-              [-1  0  0  0],
-              'denominators': [1, 1, x0, 1],
+            {0: {'edges': 13,
               'edge_diff': 6,
-              'edges': 13,
               'green_vertices': [0, 1, 3],
               'green_vertices_diff': {'added': [0], 'removed': []},
               'red_vertices': [2],
               'red_vertices_diff': {'added': [], 'removed': [0]},
-              'sinks': [],
-              'sinks_diff': {'added': [], 'removed': [2]},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [],
               'sources_diff': {'added': [], 'removed': []},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}},
-             1: {'d_matrix': [ 1  4  1  0]
-              [ 0  1  0  0]
+              'sinks': [],
+              'sinks_diff': {'added': [], 'removed': [2]},
+              'denominators': [1, 1, x0, 1],
+              'd_matrix': [ 0  0  1  0]
+              [ 0 -1  0  0]
               [ 0  0  0 -1]
-              [ 1  4  0  0],
-              'denominators': [x0*x3, x0^4*x1*x3^4, x0, 1],
+              [-1  0  0  0]},
+             1: {'edges': 9,
               'edge_diff': 2,
-              'edges': 9,
               'green_vertices': [0, 3],
               'green_vertices_diff': {'added': [0], 'removed': [1]},
               'red_vertices': [1, 2],
               'red_vertices_diff': {'added': [1], 'removed': [0]},
-              'sinks': [2],
-              'sinks_diff': {'added': [], 'removed': []},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [],
               'sources_diff': {'added': [], 'removed': []},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}},
-             2: {'d_matrix': [ 1  0  0  0]
-              [ 0 -1  0  0]
+              'sinks': [2],
+              'sinks_diff': {'added': [], 'removed': []},
+              'denominators': [x0*x3, x0^4*x1*x3^4, x0, 1],
+              'd_matrix': [ 1  4  1  0]
+              [ 0  1  0  0]
               [ 0  0  0 -1]
-              [ 1  0  1  0],
-              'denominators': [x0*x3, 1, x3, 1],
+              [ 1  4  0  0]},
+             2: {'edges': 7,
               'edge_diff': 0,
-              'edges': 7,
               'green_vertices': [1, 2, 3],
               'green_vertices_diff': {'added': [2], 'removed': []},
               'red_vertices': [0],
               'red_vertices_diff': {'added': [], 'removed': [2]},
-              'sinks': [],
-              'sinks_diff': {'added': [], 'removed': [2]},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [2],
               'sources_diff': {'added': [2], 'removed': []},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}},
-             3: {'d_matrix': [ 1  0  1  1]
+              'sinks': [],
+              'sinks_diff': {'added': [], 'removed': [2]},
+              'denominators': [x0*x3, 1, x3, 1],
+              'd_matrix': [ 1  0  0  0]
               [ 0 -1  0  0]
-              [ 0  0  0  1]
-              [ 1  0  0  1],
-              'denominators': [x0*x3, 1, x0, x0*x2*x3],
+              [ 0  0  0 -1]
+              [ 1  0  1  0]},
+             3: {'edges': 6,
               'edge_diff': -1,
-              'edges': 6,
               'green_vertices': [1],
               'green_vertices_diff': {'added': [], 'removed': [3]},
               'red_vertices': [0, 2, 3],
               'red_vertices_diff': {'added': [3], 'removed': []},
-              'sinks': [2],
-              'sinks_diff': {'added': [], 'removed': []},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [1],
               'sources_diff': {'added': [1], 'removed': []},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}}}
+              'sinks': [2],
+              'sinks_diff': {'added': [], 'removed': []},
+              'denominators': [x0*x3, 1, x0, x0*x2*x3],
+              'd_matrix': [ 1  0  1  1]
+              [ 0 -1  0  0]
+              [ 0  0  0  1]
+              [ 1  0  0  1]}}
 
             sage: S = ClusterSeed(['A',3]).principal_extension()
             sage: S.mutation_analysis()
-            {0: {'d_matrix': [ 1  0  0]
-              [ 0 -1  0]
-              [ 0  0 -1],
-              'denominators': [x0, 1, 1],
-              'green_vertices': [1, 2],
+            {0: {'green_vertices': [1, 2],
               'green_vertices_diff': {'added': [], 'removed': [0]},
               'red_vertices': [0],
               'red_vertices_diff': {'added': [0], 'removed': []},
-              'sinks': [],
-              'sinks_diff': {'added': [], 'removed': [1]},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [4, 5],
               'sources_diff': {'added': [], 'removed': [3]},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}},
-             1: {'d_matrix': [-1  0  0]
-              [ 0  1  0]
-              [ 0  0 -1],
-              'denominators': [1, x1, 1],
-              'green_vertices': [0, 2],
+              'sinks': [],
+              'sinks_diff': {'added': [], 'removed': [1]},
+              'denominators': [x0, 1, 1],
+              'd_matrix': [ 1  0  0]
+              [ 0 -1  0]
+              [ 0  0 -1]},
+             1: {'green_vertices': [0, 2],
               'green_vertices_diff': {'added': [], 'removed': [1]},
               'red_vertices': [1],
               'red_vertices_diff': {'added': [1], 'removed': []},
-              'sinks': [0, 2, 4],
-              'sinks_diff': {'added': [0, 2, 4], 'removed': [1]},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [1, 3, 5],
               'sources_diff': {'added': [1], 'removed': [4]},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}},
-             2: {'d_matrix': [-1  0  0]
-              [ 0 -1  0]
-              [ 0  0  1],
-              'denominators': [1, 1, x2],
-              'green_vertices': [0, 1],
+              'sinks': [0, 2, 4],
+              'sinks_diff': {'added': [0, 2, 4], 'removed': [1]},
+              'denominators': [1, x1, 1],
+              'd_matrix': [-1  0  0]
+              [ 0  1  0]
+              [ 0  0 -1]},
+             2: {'green_vertices': [0, 1],
               'green_vertices_diff': {'added': [], 'removed': [2]},
               'red_vertices': [2],
               'red_vertices_diff': {'added': [2], 'removed': []},
-              'sinks': [],
-              'sinks_diff': {'added': [], 'removed': [1]},
+              'urban_renewals': [],
+              'urban_renewals_diff': {'added': [], 'removed': []},
               'sources': [3, 4],
               'sources_diff': {'added': [], 'removed': [5]},
-              'urban_renewals': [],
-              'urban_renewals_diff': {'added': [], 'removed': []}}}
+              'sinks': [],
+              'sinks_diff': {'added': [], 'removed': [1]},
+              'denominators': [1, 1, x2],
+              'd_matrix': [-1  0  0]
+              [ 0 -1  0]
+              [ 0  0  1]}}
 
         """
 
diff --git a/src/sage/combinat/combinatorial_map.py b/src/sage/combinat/combinatorial_map.py
index 03075615bd..0be1240a94 100644
--- a/src/sage/combinat/combinatorial_map.py
+++ b/src/sage/combinat/combinatorial_map.py
@@ -257,8 +257,8 @@ class CombinatorialMap(object):
         EXAMPLES::
 
             sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-            sage: import imp
-            sage: _ = imp.reload(sage.combinat.permutation)
+            sage: import importlib
+            sage: _ = importlib.reload(sage.combinat.permutation)
             sage: p = Permutation([1,3,2,4])
             sage: p.left_tableau.__repr__()
             'Combinatorial map: Robinson-Schensted insertion tableau'
@@ -272,8 +272,8 @@ class CombinatorialMap(object):
         EXAMPLES::
 
             sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-            sage: import imp
-            sage: _ = imp.reload(sage.combinat.permutation)
+            sage: import importlib
+            sage: _ = importlib.reload(sage.combinat.permutation)
             sage: p = Permutation([1,3,2,4])
             sage: cm = p.left_tableau; cm
             Combinatorial map: Robinson-Schensted insertion tableau
@@ -293,8 +293,8 @@ class CombinatorialMap(object):
         EXAMPLES::
 
             sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-            sage: import imp
-            sage: _ = imp.reload(sage.combinat.permutation)
+            sage: import importlib
+            sage: _ = importlib.reload(sage.combinat.permutation)
             sage: p = Permutation([1,3,2,4])
             sage: p.left_tableau #indirect doctest
             Combinatorial map: Robinson-Schensted insertion tableau
@@ -309,8 +309,8 @@ class CombinatorialMap(object):
         EXAMPLES::
 
             sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-            sage: import imp
-            sage: _ = imp.reload(sage.combinat.permutation)
+            sage: import importlib
+            sage: _ = importlib.reload(sage.combinat.permutation)
             sage: p = Permutation([1,3,2,4])
             sage: cm = type(p).left_tableau; cm
             Combinatorial map: Robinson-Schensted insertion tableau
@@ -335,8 +335,8 @@ class CombinatorialMap(object):
         EXAMPLES::
 
             sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-            sage: import imp
-            sage: _ = imp.reload(sage.combinat.permutation)
+            sage: import importlib
+            sage: _ = importlib.reload(sage.combinat.permutation)
             sage: from sage.combinat.permutation import Permutation
             sage: pi = Permutation([1,3,2])
             sage: f = pi.reverse
@@ -400,8 +400,8 @@ def combinatorial_maps_in_class(cls):
     EXAMPLES::
 
         sage: sage.combinat.combinatorial_map.combinatorial_map = sage.combinat.combinatorial_map.combinatorial_map_wrapper
-        sage: import imp
-        sage: _ = imp.reload(sage.combinat.permutation)
+        sage: import importlib
+        sage: _ = importlib.reload(sage.combinat.permutation)
         sage: from sage.combinat.combinatorial_map import combinatorial_maps_in_class
         sage: p = Permutation([1,3,2,4])
         sage: cmaps = combinatorial_maps_in_class(p)
diff --git a/src/sage/combinat/crystals/kirillov_reshetikhin.py b/src/sage/combinat/crystals/kirillov_reshetikhin.py
index afcc1fc669..95161c35a6 100644
--- a/src/sage/combinat/crystals/kirillov_reshetikhin.py
+++ b/src/sage/combinat/crystals/kirillov_reshetikhin.py
@@ -1188,11 +1188,11 @@ class KR_type_E6(KirillovReshetikhinCrystalFromPromotion):
 
             sage: K = crystals.KirillovReshetikhin(['E',6,1],2,1)
             sage: K.highest_weight_dict_inv()
-            {((-2, 0, 1, 0, 0, 0, 0), 1): [[(2, -1), (1,)]],
+            {((0, 0, 0, 0, 0, 0, 0), 0): [],
+             ((-2, 0, 1, 0, 0, 0, 0), 1): [[(2, -1), (1,)]],
              ((-1, -1, 0, 0, 0, 1, 0), 1): [[(5, -3), (-1, 3)]],
-             ((0, -2, 0, 1, 0, 0, 0), 1): [[(-1,), (-1, 3)]],
-             ((0, 0, 0, 0, 0, 0, 0), 0): [],
-             ((0, 0, 0, 0, 0, 0, 0), 1): [[(1, -3), (-1, 3)]]}
+             ((0, 0, 0, 0, 0, 0, 0), 1): [[(1, -3), (-1, 3)]],
+             ((0, -2, 0, 1, 0, 0, 0), 1): [[(-1,), (-1, 3)]]}
         """
         hw = [x for x in self.hw_auxiliary() if x.epsilon(6) == 0]
         dic = {(self.affine_weight(x), len(x)): x for x in hw}
@@ -1944,8 +1944,8 @@ class KR_type_box(KirillovReshetikhinGenericCrystal, AffineCrystalFromClassical)
             sage: K.highest_weight_dict()
             {[]: [],
              [2]: [[1]],
-             [2, 2]: [[1], [2]],
              [4]: [[1, 1]],
+             [2, 2]: [[1], [2]],
              [4, 2]: [[1, 1], [2]],
              [4, 4]: [[1, 1], [2, 2]]}
         """
@@ -1964,8 +1964,8 @@ class KR_type_box(KirillovReshetikhinGenericCrystal, AffineCrystalFromClassical)
             sage: K.ambient_highest_weight_dict()
             {[]: [],
              [2]: [[1, 1]],
-             [2, 2]: [[1, 1], [2, 2]],
              [4]: [[1, 1, 1, 1]],
+             [2, 2]: [[1, 1], [2, 2]],
              [4, 2]: [[1, 1, 1, 1], [2, 2]],
              [4, 4]: [[1, 1, 1, 1], [2, 2, 2, 2]]}
         """
diff --git a/src/sage/combinat/crystals/mv_polytopes.py b/src/sage/combinat/crystals/mv_polytopes.py
index 25fdd16c3f..d22d1acccc 100644
--- a/src/sage/combinat/crystals/mv_polytopes.py
+++ b/src/sage/combinat/crystals/mv_polytopes.py
@@ -452,10 +452,10 @@ class MVPolytopes(PBWCrystal):
 
             sage: MV = crystals.infinity.MVPolytopes(['F', 4])
             sage: MV.latex_options()
-            {'P': Ambient space of the Root system of type ['F', 4],
-             'circle_size': 0.1,
+            {'projection': True,
              'mark_endpoints': True,
-             'projection': True}
+             'P': Ambient space of the Root system of type ['F', 4],
+             'circle_size': 0.1}
         """
         from copy import copy
         return copy(self._latex_options)
diff --git a/src/sage/combinat/dyck_word.py b/src/sage/combinat/dyck_word.py
index 89f3734bc0..9fdb92ab85 100644
--- a/src/sage/combinat/dyck_word.py
+++ b/src/sage/combinat/dyck_word.py
@@ -431,12 +431,12 @@ class DyckWord(CombinatorialElement):
 
             sage: D = DyckWord([1,0,1,0,1,0])
             sage: D.latex_options()
-            {'bounce path': False,
-             'color': black,
+            {'tikz_scale': 1,
              'diagonal': False,
              'line width': 2,
+             'color': black,
+             'bounce path': False,
              'peaks': False,
-             'tikz_scale': 1,
              'valleys': False}
 
         .. TODO::
diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
index 45f15cdb5c..0a85bf72e8 100644
--- a/src/sage/combinat/finite_state_machine.py
+++ b/src/sage/combinat/finite_state_machine.py
@@ -2134,8 +2134,7 @@ class FSMState(SageObject):
             sage: A.state(0)._in_epsilon_cycle_(A)
             True
             sage: A.state(4)._epsilon_successors_(A)
-            {0: [['d', 'b', 'c']], 1: [['d'], ['d', 'b', 'c', 'a']],
-             2: [['d', 'b']]}
+            {1: [['d'], ['d', 'b', 'c', 'a']], 2: [['d', 'b']], 0: [['d', 'b', 'c']]}
             sage: A.state(4)._in_epsilon_cycle_(A)
             False
         """
@@ -7222,7 +7221,7 @@ class FiniteStateMachine(SageObject):
             sage: S.epsilon_successors(0)
             {0: [['a', 'b']], 1: [['a']]}
             sage: S.epsilon_successors(1)
-            {0: [['b']], 1: [['b', 'a']]}
+            {1: [['b', 'a']], 0: [['b']]}
         """
         return self.state(state)._epsilon_successors_(self)
 
@@ -15056,7 +15055,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
     This class has the additional attribute ``visited_states``::
 
         sage: it.visited_states
-        {0: [''], 1: ['bc'], 2: ['b']}
+        {0: [''], 2: ['b'], 1: ['bc']}
 
     This means the following (let us skip the state `0` for a moment):
     State `1` can be reached by a epsilon path which write ``'bc'`` as
@@ -15083,7 +15082,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [['c']]
         process (0 branches)
         sage: it.visited_states
-        {1: ['c'], 2: ['']}
+        {2: [''], 1: ['c']}
 
     TESTS::
 
@@ -15111,7 +15110,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [[]]
         process (0 branches)
         sage: it.visited_states
-        {1: [[], []], 2: [[]], 3: [[]], 4: [[], []]}
+        {1: [[], []], 2: [[]], 4: [[], []], 3: [[]]}
 
     At this point note that in the previous output, state `1` (from
     which we started) was also reached by a non-trivial
@@ -15135,7 +15134,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [[]]
         process (0 branches)
         sage: it.visited_states
-        {1: [[]], 2: [[], []], 3: [[]], 4: [[], []]}
+        {2: [[], []], 3: [[]], 1: [[]], 4: [[], []]}
         sage: it = _FSMProcessIteratorEpsilon_(A, initial_state=A.state(3))
         sage: for current in it:
         ....:     print(current)
@@ -15151,7 +15150,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [[]]
         process (0 branches)
         sage: it.visited_states
-        {1: [[]], 2: [[]], 3: [[], []], 4: [[], []]}
+        {3: [[], []], 1: [[]], 4: [[], []], 2: [[]]}
         sage: it = _FSMProcessIteratorEpsilon_(A, initial_state=A.state(4))
         sage: for current in it:
         ....:     print(current)
@@ -15188,8 +15187,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [['b', 'c', 'e']]
         process (0 branches)
         sage: it.visited_states
-        {1: ['', 'bcd'], 2: ['b'],
-         3: ['bc'], 4: ['f', 'bce']}
+        {1: ['', 'bcd'], 2: ['b'], 4: ['f', 'bce'], 3: ['bc']}
         sage: it = _FSMProcessIteratorEpsilon_(T, initial_state=T.state(2),
         ....:                                  format_output=lambda o: ''.join(o))
         sage: for current in it:
@@ -15207,8 +15205,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [['c', 'd', 'f']]
         process (0 branches)
         sage: it.visited_states
-        {1: ['cd'], 2: ['', 'cdb'],
-         3: ['c'], 4: ['ce', 'cdf']}
+        {2: ['', 'cdb'], 3: ['c'], 1: ['cd'], 4: ['ce', 'cdf']}
         sage: it = _FSMProcessIteratorEpsilon_(T, initial_state=T.state(3),
         ....:                                  format_output=lambda o: ''.join(o))
         sage: for current in it:
@@ -15225,8 +15222,7 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
         +-- tape at 0, [['d', 'f']]
         process (0 branches)
         sage: it.visited_states
-        {1: ['d'], 2: ['db'],
-         3: ['', 'dbc'], 4: ['e', 'df']}
+        {3: ['', 'dbc'], 1: ['d'], 4: ['e', 'df'], 2: ['db']}
         sage: it = _FSMProcessIteratorEpsilon_(T, initial_state=T.state(4),
         ....:                                  format_output=lambda o: ''.join(o))
         sage: for current in it:
@@ -15373,9 +15369,9 @@ class _FSMProcessIteratorEpsilon_(FSMProcessIterator):
             sage: T.state(0)._epsilon_successors_(T)  # indirect doctest
             {0: [['a', 'b', 'c']], 1: [['a']], 2: [['a', 'b']]}
             sage: T.state(1)._epsilon_successors_(T)  # indirect doctest
-            {0: [['b', 'c']], 1: [['b', 'c', 'a']], 2: [['b']]}
+            {1: [['b', 'c', 'a']], 2: [['b']], 0: [['b', 'c']]}
             sage: T.state(2)._epsilon_successors_(T)  # indirect doctest
-            {0: [['c']], 1: [['c', 'a']], 2: [['c', 'a', 'b']]}
+            {2: [['c', 'a', 'b']], 0: [['c']], 1: [['c', 'a']]}
         """
         if state not in self.visited_states:
             self.visited_states[state] = []
diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
index 4feb5b52b3..243412d7d2 100644
--- a/src/sage/combinat/growth.py
+++ b/src/sage/combinat/growth.py
@@ -703,7 +703,7 @@ class GrowthDiagram(SageObject):
             sage: RuleRSK = GrowthDiagram.rules.RSK()
             sage: G = GrowthDiagram(RuleRSK, [[0,1,0], [1,0,2]])
             sage: G.filling()
-            {(0, 1): 1, (1, 0): 1, (2, 1): 2}
+            {(1, 0): 1, (0, 1): 1, (2, 1): 2}
         """
         return self._filling
 
@@ -1358,7 +1358,7 @@ class GrowthDiagram(SageObject):
 
             sage: G = GrowthDiagram(RuleRSK, pi.to_matrix())  # indirect doctest
             sage: G._filling
-            {(0, 1): 1, (1, 2): 1, (2, 0): 1, (3, 5): 1, (4, 3): 1, (5, 4): 1}
+            {(2, 0): 1, (0, 1): 1, (1, 2): 1, (4, 3): 1, (5, 4): 1, (3, 5): 1}
             sage: G.shape()
             [6, 6, 6, 6, 6, 6] / []
 
@@ -1382,7 +1382,7 @@ class GrowthDiagram(SageObject):
 
             sage: G = GrowthDiagram(RuleRSK, [[1,0,1],[0,1]])  # indirect doctest
             sage: G._filling
-            {(0, 0): 1, (1, 1): 1, (2, 0): 1}
+            {(0, 0): 1, (2, 0): 1, (1, 1): 1}
             sage: G.shape()
             [3, 2] / []
 
@@ -1390,7 +1390,7 @@ class GrowthDiagram(SageObject):
 
             sage: G = GrowthDiagram(RuleRSK, [[1,0,1],[0,1]], shape=SkewPartition([[3,2],[1]]))  # indirect doctest
             sage: G._filling
-            {(0, 0): 1, (1, 1): 1, (2, 0): 1}
+            {(0, 0): 1, (2, 0): 1, (1, 1): 1}
             sage: G.shape()
             [3, 2] / [1]
 
@@ -1538,14 +1538,14 @@ class GrowthDiagram(SageObject):
             sage: labels = [[], [1], [2], [2,1], [1,1], [1], []]
             sage: G = GrowthDiagram(RuleRSK, labels=labels)  # indirect doctest
             sage: G._filling
-            {(0, 1): 1, (1, 2): 1, (2, 0): 1}
+            {(1, 2): 1, (0, 1): 1, (2, 0): 1}
             sage: G._in_labels
             [[], [], [], [], [], [], []]
 
             sage: labels = [[], [1], [2], [3], [3, 1], [3, 2], [4, 2], [4, 1], [3, 1], [2, 1], [1, 1], [1], []]
             sage: G = GrowthDiagram(RuleRSK, labels=labels)  # indirect doctest
             sage: G._filling
-            {(0, 1): 1, (1, 2): 1, (2, 5): 1, (3, 0): 1, (4, 3): 1, (5, 4): 1}
+            {(2, 5): 1, (5, 4): 1, (4, 3): 1, (1, 2): 1, (0, 1): 1, (3, 0): 1}
 
             sage: labels = [[],[1],[1],[2],[2],[2,1],[2]]
             sage: G = GrowthDiagram(RuleRSK, labels=labels)
diff --git a/src/sage/combinat/integer_lists/base.pyx b/src/sage/combinat/integer_lists/base.pyx
index 2b3a740fb9..bb1499483f 100644
--- a/src/sage/combinat/integer_lists/base.pyx
+++ b/src/sage/combinat/integer_lists/base.pyx
@@ -228,16 +228,16 @@ cdef class IntegerListsBackend(object):
             sage: from sage.combinat.integer_lists.base import IntegerListsBackend
             sage: C = IntegerListsBackend(2, length=3)
             sage: C.__getstate__()
-            {'ceiling': <sage.combinat.integer_lists.base.Envelope object at ...>,
-             'floor': <sage.combinat.integer_lists.base.Envelope object at ...>,
-             'max_length': 3,
-             'max_part': inf,
-             'max_slope': inf,
+            {'min_sum': 2,
              'max_sum': 2,
              'min_length': 3,
+             'max_length': 3,
              'min_part': 0,
+             'max_part': inf,
              'min_slope': -inf,
-             'min_sum': 2}
+             'max_slope': inf,
+             'floor': <sage.combinat.integer_lists.base.Envelope object at ...>,
+             'ceiling': <sage.combinat.integer_lists.base.Envelope object at ...>}
         """
         return {"min_sum": self.min_sum,
                 "max_sum": self.max_sum,
diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py
index 39dee9914b..1ed6067660 100644
--- a/src/sage/combinat/k_tableau.py
+++ b/src/sage/combinat/k_tableau.py
@@ -2910,22 +2910,22 @@ class StrongTableau(ClonableList):
 
             sage: T = StrongTableau([[-1,-2,-4,7],[-3,6,-6,8],[4,-7],[-5,-8]], 3)
             sage: T.cells_head_dictionary()
-            {1: [(0, 0)],
-             2: [(0, 1)],
-             3: [(1, 0)],
+            {5: [(3, 0)],
              4: [(2, 0), (0, 2)],
-             5: [(3, 0)],
-             6: [(1, 2)],
+             8: [(3, 1), (1, 3)],
+             3: [(1, 0)],
              7: [(2, 1), (0, 3)],
-             8: [(3, 1), (1, 3)]}
+             1: [(0, 0)],
+             2: [(0, 1)],
+             6: [(1, 2)]}
             sage: T = StrongTableau([[None, 4, -4, -6, -7, 8, 8, -8], [None, -5, 8, 8, 8], [-3, 6]],3)
             sage: T.cells_head_dictionary()
             {1: [(2, 0)],
-             2: [(0, 2)],
-             3: [(1, 1)],
              4: [(2, 1), (0, 3)],
-             5: [(0, 4)],
-             6: [(1, 4), (0, 7)]}
+             3: [(1, 1)],
+             2: [(0, 2)],
+             6: [(1, 4), (0, 7)],
+             5: [(0, 4)]}
              sage: StrongTableau([[None, None], [None, -1]], 4).cells_head_dictionary()
              {1: [(1, 1)]}
 
@@ -4421,21 +4421,21 @@ class StrongTableaux(UniqueRepresentation, Parent):
         EXAMPLES::
 
             sage: StrongTableaux.cells_head_dictionary([[1,2,4,7],[3,6,6,8],[4,7],[5,8]])
-            {1: [(0, 0)],
-             2: [(0, 1)],
-             3: [(1, 0)],
+            {5: [(3, 0)],
              4: [(2, 0), (0, 2)],
-             5: [(3, 0)],
-             6: [(1, 2)],
+             8: [(3, 1), (1, 3)],
+             3: [(1, 0)],
              7: [(2, 1), (0, 3)],
-             8: [(3, 1), (1, 3)]}
+             1: [(0, 0)],
+             2: [(0, 1)],
+             6: [(1, 2)]}
             sage: StrongTableaux.cells_head_dictionary([[None, 2, 2, 4, 5, 6, 6, 6], [None, 3, 6, 6, 6], [1, 4]])
             {1: [(2, 0)],
-             2: [(0, 2)],
-             3: [(1, 1)],
              4: [(2, 1), (0, 3)],
-             5: [(0, 4)],
-             6: [(1, 4), (0, 7)]}
+             3: [(1, 1)],
+             2: [(0, 2)],
+             6: [(1, 4), (0, 7)],
+             5: [(0, 4)]}
 
         TESTS::
 
diff --git a/src/sage/combinat/matrices/latin.py b/src/sage/combinat/matrices/latin.py
index 97dcce10ae..a3477f69f1 100644
--- a/src/sage/combinat/matrices/latin.py
+++ b/src/sage/combinat/matrices/latin.py
@@ -1101,68 +1101,68 @@ class LatinSquare:
               [14, 30, 47],
               [15, 31, 47]],
              {(0, 16, 32): (0, 0, 0),
-              (0, 20, 36): (1, 0, 0),
-              (0, 24, 40): (2, 0, 0),
-              (0, 28, 44): (3, 0, 0),
               (1, 17, 32): (0, 0, 1),
-              (1, 21, 36): (1, 0, 1),
-              (1, 25, 40): (2, 0, 1),
-              (1, 29, 44): (3, 0, 1),
               (2, 18, 32): (0, 0, 2),
-              (2, 22, 36): (1, 0, 2),
-              (2, 26, 40): (2, 0, 2),
-              (2, 30, 44): (3, 0, 2),
               (3, 19, 32): (0, 0, 3),
-              (3, 23, 36): (1, 0, 3),
-              (3, 27, 40): (2, 0, 3),
-              (3, 31, 44): (3, 0, 3),
               (4, 16, 33): (0, 1, 0),
-              (4, 20, 37): (1, 1, 0),
-              (4, 24, 41): (2, 1, 0),
-              (4, 28, 45): (3, 1, 0),
               (5, 17, 33): (0, 1, 1),
-              (5, 21, 37): (1, 1, 1),
-              (5, 25, 41): (2, 1, 1),
-              (5, 29, 45): (3, 1, 1),
               (6, 18, 33): (0, 1, 2),
-              (6, 22, 37): (1, 1, 2),
-              (6, 26, 41): (2, 1, 2),
-              (6, 30, 45): (3, 1, 2),
               (7, 19, 33): (0, 1, 3),
-              (7, 23, 37): (1, 1, 3),
-              (7, 27, 41): (2, 1, 3),
-              (7, 31, 45): (3, 1, 3),
               (8, 16, 34): (0, 2, 0),
-              (8, 20, 38): (1, 2, 0),
-              (8, 24, 42): (2, 2, 0),
-              (8, 28, 46): (3, 2, 0),
               (9, 17, 34): (0, 2, 1),
-              (9, 21, 38): (1, 2, 1),
-              (9, 25, 42): (2, 2, 1),
-              (9, 29, 46): (3, 2, 1),
               (10, 18, 34): (0, 2, 2),
-              (10, 22, 38): (1, 2, 2),
-              (10, 26, 42): (2, 2, 2),
-              (10, 30, 46): (3, 2, 2),
               (11, 19, 34): (0, 2, 3),
-              (11, 23, 38): (1, 2, 3),
-              (11, 27, 42): (2, 2, 3),
-              (11, 31, 46): (3, 2, 3),
               (12, 16, 35): (0, 3, 0),
-              (12, 20, 39): (1, 3, 0),
-              (12, 24, 43): (2, 3, 0),
-              (12, 28, 47): (3, 3, 0),
               (13, 17, 35): (0, 3, 1),
-              (13, 21, 39): (1, 3, 1),
-              (13, 25, 43): (2, 3, 1),
-              (13, 29, 47): (3, 3, 1),
               (14, 18, 35): (0, 3, 2),
-              (14, 22, 39): (1, 3, 2),
-              (14, 26, 43): (2, 3, 2),
-              (14, 30, 47): (3, 3, 2),
               (15, 19, 35): (0, 3, 3),
+              (0, 20, 36): (1, 0, 0),
+              (1, 21, 36): (1, 0, 1),
+              (2, 22, 36): (1, 0, 2),
+              (3, 23, 36): (1, 0, 3),
+              (4, 20, 37): (1, 1, 0),
+              (5, 21, 37): (1, 1, 1),
+              (6, 22, 37): (1, 1, 2),
+              (7, 23, 37): (1, 1, 3),
+              (8, 20, 38): (1, 2, 0),
+              (9, 21, 38): (1, 2, 1),
+              (10, 22, 38): (1, 2, 2),
+              (11, 23, 38): (1, 2, 3),
+              (12, 20, 39): (1, 3, 0),
+              (13, 21, 39): (1, 3, 1),
+              (14, 22, 39): (1, 3, 2),
               (15, 23, 39): (1, 3, 3),
+              (0, 24, 40): (2, 0, 0),
+              (1, 25, 40): (2, 0, 1),
+              (2, 26, 40): (2, 0, 2),
+              (3, 27, 40): (2, 0, 3),
+              (4, 24, 41): (2, 1, 0),
+              (5, 25, 41): (2, 1, 1),
+              (6, 26, 41): (2, 1, 2),
+              (7, 27, 41): (2, 1, 3),
+              (8, 24, 42): (2, 2, 0),
+              (9, 25, 42): (2, 2, 1),
+              (10, 26, 42): (2, 2, 2),
+              (11, 27, 42): (2, 2, 3),
+              (12, 24, 43): (2, 3, 0),
+              (13, 25, 43): (2, 3, 1),
+              (14, 26, 43): (2, 3, 2),
               (15, 27, 43): (2, 3, 3),
+              (0, 28, 44): (3, 0, 0),
+              (1, 29, 44): (3, 0, 1),
+              (2, 30, 44): (3, 0, 2),
+              (3, 31, 44): (3, 0, 3),
+              (4, 28, 45): (3, 1, 0),
+              (5, 29, 45): (3, 1, 1),
+              (6, 30, 45): (3, 1, 2),
+              (7, 31, 45): (3, 1, 3),
+              (8, 28, 46): (3, 2, 0),
+              (9, 29, 46): (3, 2, 1),
+              (10, 30, 46): (3, 2, 2),
+              (11, 31, 46): (3, 2, 3),
+              (12, 28, 47): (3, 3, 0),
+              (13, 29, 47): (3, 3, 1),
+              (14, 30, 47): (3, 3, 2),
               (15, 31, 47): (3, 3, 3)})
         """
 
@@ -2771,12 +2771,12 @@ def dlxcpp_rows_and_map(P):
           [2, 6, 11],
           [3, 7, 11]],
          {(0, 4, 8): (0, 0, 0),
-          (0, 6, 10): (1, 0, 0),
           (1, 5, 8): (0, 0, 1),
-          (1, 7, 10): (1, 0, 1),
           (2, 4, 9): (0, 1, 0),
-          (2, 6, 11): (1, 1, 0),
           (3, 5, 9): (0, 1, 1),
+          (0, 6, 10): (1, 0, 0),
+          (1, 7, 10): (1, 0, 1),
+          (2, 6, 11): (1, 1, 0),
           (3, 7, 11): (1, 1, 1)})
     """
     assert P.nrows() == P.ncols()
diff --git a/src/sage/combinat/multiset_partition_into_sets_ordered.py b/src/sage/combinat/multiset_partition_into_sets_ordered.py
index b8dc15efab..b25d23bd24 100755
--- a/src/sage/combinat/multiset_partition_into_sets_ordered.py
+++ b/src/sage/combinat/multiset_partition_into_sets_ordered.py
@@ -1498,15 +1498,15 @@ class OrderedMultisetPartitionsIntoSets(UniqueRepresentation, Parent):
 
             sage: c = {"length":4, "max_order":6, "alphabet":[2,4,5,6]}
             sage: OrderedMultisetPartitionsIntoSets(**c).constraints
-            {'alphabet': frozenset({2, 4, 5, 6}), 'length': 4, 'max_order': 6}
+            {'length': 4, 'max_order': 6, 'alphabet': frozenset({2, 4, 5, 6})}
             sage: OrderedMultisetPartitionsIntoSets(17, **c).constraints
-            {'alphabet': frozenset({2, 4, 5, 6}), 'length': 4, 'max_order': 6}
+            {'length': 4, 'max_order': 6, 'alphabet': frozenset({2, 4, 5, 6})}
             sage: OrderedMultisetPartitionsIntoSets(17, **c).full_constraints
-            {'alphabet': frozenset({2, 4, 5, 6}), 'length': 4, 'max_order': 6, 'size': 17}
+            {'size': 17, 'length': 4, 'max_order': 6, 'alphabet': frozenset({2, 4, 5, 6})}
 
             sage: c = {"length":4, "min_length":5, "max_order":6, "order":5, "alphabet":4}
             sage: OrderedMultisetPartitionsIntoSets(**c).full_constraints
-            {'alphabet': frozenset({1, 2, 3, 4}), 'length': 4, 'order': 5}
+            {'alphabet': frozenset({1, 2, 3, 4}), 'order': 5, 'length': 4}
             sage: OrderedMultisetPartitionsIntoSets(**c).constraints
             {'length': 4}
             sage: OrderedMultisetPartitionsIntoSets(4, 5, **c).constraints
diff --git a/src/sage/combinat/ncsf_qsym/tutorial.py b/src/sage/combinat/ncsf_qsym/tutorial.py
index ac452cdb14..dc1af4a512 100644
--- a/src/sage/combinat/ncsf_qsym/tutorial.py
+++ b/src/sage/combinat/ncsf_qsym/tutorial.py
@@ -115,7 +115,7 @@ degrees, and the support::
     [M[1, 2], M[3, 3], M[6]]
 
     sage: z.monomial_coefficients()
-    {[1, 2]: 3, [3, 3]: 2, [6]: 1}
+    {[3, 3]: 2, [6]: 1, [1, 2]: 3}
 
 As with the symmetric functions package, the quasisymmetric function ``1``
 has several instantiations. However, the most obvious way to write ``1``
diff --git a/src/sage/combinat/parallelogram_polyomino.py b/src/sage/combinat/parallelogram_polyomino.py
index 47d2379910..cb628b26c8 100644
--- a/src/sage/combinat/parallelogram_polyomino.py
+++ b/src/sage/combinat/parallelogram_polyomino.py
@@ -559,16 +559,16 @@ EXAMPLES::
     ....: )
     sage: opt = ParallelogramPolyominoesOptions['tikz_options']
     sage: opt
-    {'color_bounce_0': u'red',
-     'color_bounce_1': u'blue',
-     'color_line': u'black',
-     'color_point': u'black',
+    {'scale': 1,
      'line_size': 1,
-     'mirror': None,
      'point_size': 3.5,
+     'color_line': 'black',
+     'color_point': 'black',
+     'color_bounce_0': 'red',
+     'color_bounce_1': 'blue',
+     'translation': [0, 0],
      'rotation': 0,
-     'scale': 1,
-     'translation': [0, 0]}
+     'mirror': None}
 """
 
 
@@ -2566,16 +2566,16 @@ class ParallelogramPolyomino(ClonableList):
 
             sage: pp = ParallelogramPolyomino([[0, 1], [1, 0]])
             sage: pp.get_tikz_options()
-            {'color_bounce_0': u'red',
-             'color_bounce_1': u'blue',
-             'color_line': u'black',
-             'color_point': u'black',
+            {'scale': 1,
              'line_size': 1,
-             'mirror': None,
              'point_size': 3.5,
+             'color_line': 'black',
+             'color_point': 'black',
+             'color_bounce_0': 'red',
+             'color_bounce_1': 'blue',
+             'translation': [0, 0],
              'rotation': 0,
-             'scale': 1,
-             'translation': [0, 0]}
+             'mirror': None}
         """
         return self.get_options()['tikz_options']
 
diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py
index e6f3b365db..4130afb645 100644
--- a/src/sage/combinat/partition.py
+++ b/src/sage/combinat/partition.py
@@ -3766,11 +3766,11 @@ class Partition(CombinatorialElement):
         EXAMPLES::
 
             sage: Partition([4,3,2]).block(0)
-            {-2: 1, -1: 2, 0: 2, 1: 2, 2: 1, 3: 1}
+            {0: 2, 1: 2, 2: 1, 3: 1, -1: 2, -2: 1}
             sage: Partition([4,3,2]).block(2)
             {0: 4, 1: 5}
             sage: Partition([4,3,2]).block(2, multicharge=(1,))
-            {0: 5, 1: 4}
+            {1: 4, 0: 5}
             sage: Partition([4,3,2]).block(3)
             {0: 3, 1: 3, 2: 3}
             sage: Partition([4,3,2]).block(4)
diff --git a/src/sage/combinat/partition_kleshchev.py b/src/sage/combinat/partition_kleshchev.py
index e257781f1c..5fb6e27a87 100644
--- a/src/sage/combinat/partition_kleshchev.py
+++ b/src/sage/combinat/partition_kleshchev.py
@@ -129,14 +129,14 @@ class KleshchevPartition(Partition):
 
             sage: KP = KleshchevPartitions(3, convention="regular")
             sage: KP([5,4,4,3,2]).conormal_cells()
-            {0: [(1, 4)], 1: [(5, 0), (4, 2)]}
+            {1: [(5, 0), (4, 2)], 0: [(1, 4)]}
             sage: KP([5,4,4,3,2]).conormal_cells(0)
             [(1, 4)]
             sage: KP([5,4,4,3,2]).conormal_cells(1)
             [(5, 0), (4, 2)]
             sage: KP = KleshchevPartitions(3, convention="restricted")
             sage: KP([5,4,4,3,2]).conormal_cells()
-            {0: [(1, 4), (3, 3)], 2: [(0, 5)]}
+            {2: [(0, 5)], 0: [(1, 4), (3, 3)]}
         """
         # We use a dictionary for the conormal nodes as the indexing set is Z when e=0
         conormals = defaultdict(list)   # the conormal cells of each residue
@@ -190,14 +190,14 @@ class KleshchevPartition(Partition):
 
             sage: KP = KleshchevPartitions(3, convention="regular")
             sage: KP([5,4,4,3,2]).cogood_cells()
-            {0: (1, 4), 1: (4, 2)}
+            {1: (4, 2), 0: (1, 4)}
             sage: KP([5,4,4,3,2]).cogood_cells(0)
             (1, 4)
             sage: KP([5,4,4,3,2]).cogood_cells(1)
             (4, 2)
             sage: KP = KleshchevPartitions(4, convention='restricted')
             sage: KP([5,4,4,3,2]).cogood_cells()
-            {1: (0, 5), 2: (4, 2), 3: (1, 4)}
+            {1: (0, 5), 3: (1, 4), 2: (4, 2)}
             sage: KP([5,4,4,3,2]).cogood_cells(0)
             sage: KP([5,4,4,3,2]).cogood_cells(2)
             (4, 2)
@@ -513,8 +513,8 @@ class KleshchevPartitionTuple(PartitionTuple):
 
             sage: KP = KleshchevPartitions(3, [0,1], convention="left regular")
             sage: KP([[4, 2], [5, 3, 1]]).conormal_cells()
-            {0: [(1, 2, 1), (1, 1, 3), (1, 0, 5)],
-            1: [(1, 3, 0), (0, 2, 0), (0, 1, 2), (0, 0, 4)]}
+            {1: [(1, 3, 0), (0, 2, 0), (0, 1, 2), (0, 0, 4)],
+             0: [(1, 2, 1), (1, 1, 3), (1, 0, 5)]}
             sage: KP([[4, 2], [5, 3, 1]]).conormal_cells(1)
             [(1, 3, 0), (0, 2, 0), (0, 1, 2), (0, 0, 4)]
             sage: KP([[4, 2], [5, 3, 1]]).conormal_cells(2)
@@ -583,13 +583,13 @@ class KleshchevPartitionTuple(PartitionTuple):
             sage: KP = KleshchevPartitions(3, [0,1])
             sage: pt = KP([[4, 2], [5, 3, 1]])
             sage: pt.cogood_cells()
-            {0: (1, 2, 1), 1: (1, 3, 0)}
+            {1: (1, 3, 0), 0: (1, 2, 1)}
             sage: pt.cogood_cells(0)
             (1, 2, 1)
             sage: KP = KleshchevPartitions(4, [0,1], convention="left regular")
             sage: pt = KP([[5, 2, 2], [6, 1, 1]])
             sage: pt.cogood_cells()
-            {1: (0, 0, 5), 2: (1, 3, 0)}
+            {2: (1, 3, 0), 1: (0, 0, 5)}
             sage: pt.cogood_cells(0) is None
             True
             sage: pt.cogood_cells(1) is None
@@ -711,7 +711,7 @@ class KleshchevPartitionTuple(PartitionTuple):
             sage: KP = KleshchevPartitions(4, [0,1], convention="left regular")
             sage: pt = KP([[5, 2, 2], [6, 2, 1]])
             sage: pt.good_cells()
-            {0: (0, 0, 4), 2: (1, 0, 5), 3: (0, 2, 1)}
+            {0: (0, 0, 4), 3: (0, 2, 1), 2: (1, 0, 5)}
             sage: pt.good_cells(1) is None
             True
         """
diff --git a/src/sage/combinat/partition_tuple.py b/src/sage/combinat/partition_tuple.py
index a78798746a..f478e5d043 100644
--- a/src/sage/combinat/partition_tuple.py
+++ b/src/sage/combinat/partition_tuple.py
@@ -1684,7 +1684,7 @@ class PartitionTuple(CombinatorialElement):
         EXAMPLES::
 
             sage: PartitionTuple([[2,2],[2,2]]).block(0,(0,0))
-            {-1: 2, 0: 4, 1: 2}
+            {0: 4, 1: 2, -1: 2}
             sage: PartitionTuple([[2,2],[2,2]]).block(2,(0,0))
             {0: 4, 1: 4}
             sage: PartitionTuple([[2,2],[2,2]]).block(2,(0,1))
diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
index deac1eff88..8192a77461 100644
--- a/src/sage/combinat/posets/posets.py
+++ b/src/sage/combinat/posets/posets.py
@@ -4044,7 +4044,7 @@ class FinitePoset(UniqueRepresentation, Parent):
         Since :trac:`25576`, one can ask for the isomorphism::
 
             sage: P.is_isomorphic(Q, certificate=True)
-            (True, {1: 4, 2: 5, 3: 6})
+            (True, {2: 5, 1: 4, 3: 6})
         """
         if hasattr(other, 'hasse_diagram'):
             return self.hasse_diagram().is_isomorphic(other.hasse_diagram(),
@@ -7592,60 +7592,60 @@ class FinitePoset(UniqueRepresentation, Parent):
             sage: G.edges(sort=True)
             [((-1, 0), (0, -13), None), ((-1, 0), (0, 12), None), ((-1, 0), (0, 14), None), ((-1, 0), (0, 16), None), ((0, -13), (1, -13), None), ((0, -13), (1, 12), None), ((0, -13), (1, 14), None), ((0, -13), (1, 16), None), ((0, 12), (1, 12), None), ((0, 14), (1, 12), None), ((0, 14), (1, 14), None), ((0, 16), (1, 12), None), ((0, 16), (1, 16), None), ((1, -13), (2, 0), None), ((1, 12), (2, 0), None), ((1, 14), (2, 0), None), ((1, 16), (2, 0), None)]
             sage: e
-            {((-1, 0), (0, -13)): 0,
-             ((-1, 0), (0, 12)): 0,
-             ((-1, 0), (0, 14)): 0,
-             ((-1, 0), (0, 16)): 0,
-             ((0, -13), (1, -13)): 1,
+            {((1, 12), (2, 0)): 0,
+             ((0, 16), (1, 12)): 0,
+             ((0, 16), (1, 16)): 1,
+             ((1, 14), (2, 0)): 0,
              ((0, -13), (1, 12)): 0,
              ((0, -13), (1, 14)): 0,
+             ((0, -13), (1, -13)): 1,
              ((0, -13), (1, 16)): 0,
+             ((-1, 0), (0, 16)): 0,
+             ((-1, 0), (0, -13)): 0,
+             ((-1, 0), (0, 12)): 0,
+             ((-1, 0), (0, 14)): 0,
              ((0, 12), (1, 12)): 1,
-             ((0, 14), (1, 12)): 0,
-             ((0, 14), (1, 14)): 1,
-             ((0, 16), (1, 12)): 0,
-             ((0, 16), (1, 16)): 1,
              ((1, -13), (2, 0)): 0,
-             ((1, 12), (2, 0)): 0,
-             ((1, 14), (2, 0)): 0,
-             ((1, 16), (2, 0)): 0}
+             ((1, 16), (2, 0)): 0,
+             ((0, 14), (1, 12)): 0,
+             ((0, 14), (1, 14)): 1}
             sage: qs = [[1,2,3,4,5,6,7,8,9],[[1,3],[3,4],[5,7],[1,9],[2,3]]]
             sage: Poset(qs).frank_network()
             (Digraph on 20 vertices,
-             {((-1, 0), (0, 1)): 0,
+             {((0, 2), (1, 2)): 1,
+              ((0, 5), (1, 5)): 1,
+              ((1, 6), (2, 0)): 0,
+              ((0, 8), (1, 8)): 1,
+              ((1, 3), (2, 0)): 0,
+              ((1, 9), (2, 0)): 0,
+              ((0, 1), (1, 1)): 1,
+              ((0, 7), (1, 7)): 1,
+              ((0, 7), (1, 5)): 0,
+              ((1, 2), (2, 0)): 0,
+              ((0, 4), (1, 4)): 1,
+              ((0, 4), (1, 3)): 0,
+              ((0, 4), (1, 2)): 0,
+              ((0, 4), (1, 1)): 0,
+              ((1, 5), (2, 0)): 0,
+              ((1, 8), (2, 0)): 0,
               ((-1, 0), (0, 2)): 0,
-              ((-1, 0), (0, 3)): 0,
-              ((-1, 0), (0, 4)): 0,
+              ((-1, 0), (0, 9)): 0,
               ((-1, 0), (0, 5)): 0,
               ((-1, 0), (0, 6)): 0,
-              ((-1, 0), (0, 7)): 0,
               ((-1, 0), (0, 8)): 0,
-              ((-1, 0), (0, 9)): 0,
-              ((0, 1), (1, 1)): 1,
-              ((0, 2), (1, 2)): 1,
-              ((0, 3), (1, 1)): 0,
-              ((0, 3), (1, 2)): 0,
+              ((-1, 0), (0, 1)): 0,
+              ((-1, 0), (0, 7)): 0,
+              ((-1, 0), (0, 4)): 0,
+              ((-1, 0), (0, 3)): 0,
+              ((1, 1), (2, 0)): 0,
               ((0, 3), (1, 3)): 1,
-              ((0, 4), (1, 1)): 0,
-              ((0, 4), (1, 2)): 0,
-              ((0, 4), (1, 3)): 0,
-              ((0, 4), (1, 4)): 1,
-              ((0, 5), (1, 5)): 1,
-              ((0, 6), (1, 6)): 1,
-              ((0, 7), (1, 5)): 0,
-              ((0, 7), (1, 7)): 1,
-              ((0, 8), (1, 8)): 1,
-              ((0, 9), (1, 1)): 0,
+              ((0, 3), (1, 2)): 0,
+              ((0, 3), (1, 1)): 0,
               ((0, 9), (1, 9)): 1,
-              ((1, 1), (2, 0)): 0,
-              ((1, 2), (2, 0)): 0,
-              ((1, 3), (2, 0)): 0,
+              ((0, 9), (1, 1)): 0,
               ((1, 4), (2, 0)): 0,
-              ((1, 5), (2, 0)): 0,
-              ((1, 6), (2, 0)): 0,
-              ((1, 7), (2, 0)): 0,
-              ((1, 8), (2, 0)): 0,
-              ((1, 9), (2, 0)): 0})
+              ((0, 6), (1, 6)): 1,
+              ((1, 7), (2, 0)): 0})
 
         AUTHOR:
 
diff --git a/src/sage/combinat/root_system/weyl_characters.py b/src/sage/combinat/root_system/weyl_characters.py
index 744fcda226..02a682b381 100644
--- a/src/sage/combinat/root_system/weyl_characters.py
+++ b/src/sage/combinat/root_system/weyl_characters.py
@@ -640,7 +640,7 @@ class WeylCharacterRing(CombinatorialFreeModule):
 
             sage: B2 = WeylCharacterRing("B2", style="coroots")
             sage: [B2._demazure_weights(v, word=[1,2]) for v in B2.fundamental_weights()]
-            [{(1, 0): 1, (0, 1): 1}, {(-1/2, 1/2): 1, (1/2, -1/2): 1, (1/2, 1/2): 1}]
+            [{(1, 0): 1, (0, 1): 1}, {(1/2, 1/2): 1, (1/2, -1/2): 1, (-1/2, 1/2): 1}]
         """
         alphacheck = self._space.simple_coroots()
         dd = {}
@@ -666,7 +666,7 @@ class WeylCharacterRing(CombinatorialFreeModule):
             sage: A2 = WeylCharacterRing("A2",style="coroots")
             sage: dd = {}; dd[(1,1)]=int(1)
             sage: A2._demazure_helper(dd,word=[1,2])
-            {(0, 0, 0): 1, (-1, 1, 0): 1, (1, -1, 0): 1, (1, 0, -1): 1, (0, 1, -1): 1}
+            {(1, 0, -1): 1, (0, 1, -1): 1, (1, -1, 0): 1, (0, 0, 0): 1, (-1, 1, 0): 1}
         """
         if self._style != "coroots":
             raise ValueError('_demazure_helper method unavailable. Use style="coroots".')
@@ -724,7 +724,7 @@ class WeylCharacterRing(CombinatorialFreeModule):
             sage: B2 = WeylCharacterRing("B2",style="coroots")
             sage: chi = 2*B2(1,0)
             sage: B2._weight_multiplicities(chi)
-            {(0, 0): 2, (-1, 0): 2, (1, 0): 2, (0, -1): 2, (0, 1): 2}
+            {(1, 0): 2, (0, 1): 2, (0, 0): 2, (0, -1): 2, (-1, 0): 2}
         """
         d = {}
         m = x._monomial_coefficients
@@ -988,12 +988,12 @@ class WeylCharacterRing(CombinatorialFreeModule):
             sage: v = A2._space([3,1,0]); v
             (3, 1, 0)
             sage: d = dict([(x,1) for x in v.orbit()]); d
-            {(1, 3, 0): 1,
-             (1, 0, 3): 1,
-             (3, 1, 0): 1,
+            {(3, 1, 0): 1,
+             (1, 3, 0): 1,
              (3, 0, 1): 1,
-             (0, 1, 3): 1,
-             (0, 3, 1): 1}
+             (1, 0, 3): 1,
+             (0, 3, 1): 1,
+             (0, 1, 3): 1}
             sage: A2.char_from_weights(d)
             -A2(2,1,1) - A2(2,2,0) + A2(3,1,0)
         """
@@ -1017,7 +1017,7 @@ class WeylCharacterRing(CombinatorialFreeModule):
             sage: v = A2._space([3,1,0])
             sage: d = dict([(x,1) for x in v.orbit()])
             sage: A2._char_from_weights(d)
-            {(2, 1, 1): -1, (2, 2, 0): -1, (3, 1, 0): 1}
+            {(3, 1, 0): 1, (2, 2, 0): -1, (2, 1, 1): -1}
         """
         hdict = {}
         ddict = mdict.copy()
@@ -1531,7 +1531,7 @@ class WeylCharacterRing(CombinatorialFreeModule):
 
                 sage: B2 = WeylCharacterRing("B2",style="coroots")
                 sage: B2(0,1).weight_multiplicities()
-                {(-1/2, -1/2): 1, (-1/2, 1/2): 1, (1/2, -1/2): 1, (1/2, 1/2): 1}
+                {(1/2, 1/2): 1, (1/2, -1/2): 1, (-1/2, 1/2): 1, (-1/2, -1/2): 1}
             """
             return self.parent()._weight_multiplicities(self)
 
@@ -1622,8 +1622,13 @@ def irreducible_character_freudenthal(hwv, debug=False):
     EXAMPLES::
 
         sage: WeylCharacterRing("A2")(2,1,0).weight_multiplicities() # indirect doctest
-        {(1, 1, 1): 2, (1, 2, 0): 1, (1, 0, 2): 1, (2, 1, 0): 1,
-         (2, 0, 1): 1, (0, 1, 2): 1, (0, 2, 1): 1}
+        {(2, 1, 0): 1,
+         (1, 2, 0): 1,
+         (2, 0, 1): 1,
+         (1, 1, 1): 2,
+         (0, 2, 1): 1,
+         (1, 0, 2): 1,
+         (0, 1, 2): 1}
     """
     L = hwv.parent()
     rho = L.rho()
diff --git a/src/sage/combinat/set_partition.py b/src/sage/combinat/set_partition.py
index ef78e8b4e2..fde60b25b1 100644
--- a/src/sage/combinat/set_partition.py
+++ b/src/sage/combinat/set_partition.py
@@ -626,13 +626,13 @@ class SetPartition(AbstractSetPartition):
             sage: SP.set_latex_options(tikz_scale=2,plot='linear',fill=True,color='blue',angle=45)
             sage: SP.set_latex_options(plot='cyclic')
             sage: SP.latex_options()
-            {'angle': 45,
-             'color': 'blue',
-             'fill': True,
+            {'tikz_scale': 2,
              'plot': 'cyclic',
-             'radius': '1cm',
+             'fill': True,
+             'color': 'blue',
+             'angle': 45,
              'show_labels': True,
-             'tikz_scale': 2}
+             'radius': '1cm'}
 
         """
         valid_args = ['tikz_scale', 'plot', 'color', 'fill', 'show_labels',
@@ -660,13 +660,13 @@ class SetPartition(AbstractSetPartition):
         EXAMPLES::
 
             sage: SP = SetPartition([[1,6], [3,5,4]]); SP.latex_options()
-            {'angle': 0,
+            {'tikz_scale': 1,
+             'plot': None,
              'color': 'black',
              'fill': False,
-             'plot': None,
-             'radius': '1cm',
              'show_labels': True,
-             'tikz_scale': 1}
+             'radius': '1cm',
+             'angle': 0}
         """
         opts = self._latex_options.copy()
         if "tikz_scale" not in opts:
diff --git a/src/sage/combinat/similarity_class_type.py b/src/sage/combinat/similarity_class_type.py
index c52ea6e394..7a7f0da433 100644
--- a/src/sage/combinat/similarity_class_type.py
+++ b/src/sage/combinat/similarity_class_type.py
@@ -1593,7 +1593,7 @@ def matrix_centralizer_cardinalities_length_two(n, q = None, selftranspose = Fal
         (q^4 - q^2, 1/2*q^4 - 1/2*q^3)]
         sage: from sage.combinat.similarity_class_type import dictionary_from_generator
         sage: dictionary_from_generator(matrix_centralizer_cardinalities_length_two(2, q = 2))
-        {4: 4, 8: 8, 12: 4, 16: 2, 32: 4, 48: 2, 96: 4}
+        {32: 4, 96: 4, 4: 4, 8: 8, 12: 4, 16: 2, 48: 2}
     """
     if q is None:
         q = FractionField(QQ['q']).gen()
diff --git a/src/sage/combinat/symmetric_group_representations.py b/src/sage/combinat/symmetric_group_representations.py
index d3c2495e44..5394c31a6c 100644
--- a/src/sage/combinat/symmetric_group_representations.py
+++ b/src/sage/combinat/symmetric_group_representations.py
@@ -540,8 +540,8 @@ class YoungRepresentation_generic(SymmetricGroupRepresentation_generic_class):
             sage: orth._tableau_dict
             {(0, -1, 2, 1, 0): [[1, 2, 3], [4, 5]],
              (0, 2, -1, 1, 0): [[1, 2, 4], [3, 5]],
-             (0, 2, 1, -1, 0): [[1, 3, 4], [2, 5]],
              (2, 0, -1, 1, 0): [[1, 2, 5], [3, 4]],
+             (0, 2, 1, -1, 0): [[1, 3, 4], [2, 5]],
              (2, 0, 1, -1, 0): [[1, 3, 5], [2, 4]]}
         """
         # construct a dictionary pairing vertices with tableau
@@ -565,8 +565,8 @@ class YoungRepresentation_generic(SymmetricGroupRepresentation_generic_class):
             sage: orth._word_dict
             {(0, -1, 2, 1, 0): (4, 5, 1, 2, 3),
              (0, 2, -1, 1, 0): (3, 5, 1, 2, 4),
-             (0, 2, 1, -1, 0): (2, 5, 1, 3, 4),
              (2, 0, -1, 1, 0): (3, 4, 1, 2, 5),
+             (0, 2, 1, -1, 0): (2, 5, 1, 3, 4),
              (2, 0, 1, -1, 0): (2, 4, 1, 3, 5)}
         """
         word_dict = {}
diff --git a/src/sage/combinat/words/finite_word.py b/src/sage/combinat/words/finite_word.py
index a3bdb3d433..6c2f088db5 100644
--- a/src/sage/combinat/words/finite_word.py
+++ b/src/sage/combinat/words/finite_word.py
@@ -4832,9 +4832,9 @@ class FiniteWord_class(Word_class):
         EXAMPLES::
 
             sage: Word([2,1,4,2,3,4,2]).evaluation_dict()
-            {1: 1, 2: 3, 3: 1, 4: 2}
+            {2: 3, 1: 1, 4: 2, 3: 1}
             sage: Word('badbcdb').evaluation_dict()
-            {'a': 1, 'b': 3, 'c': 1, 'd': 2}
+            {'b': 3, 'a': 1, 'd': 2, 'c': 1}
             sage: Word().evaluation_dict()
             {}
 
@@ -7109,9 +7109,9 @@ def evaluation_dict(w):
 
         sage: from sage.combinat.words.finite_word import evaluation_dict
         sage: evaluation_dict([2,1,4,2,3,4,2])
-        {1: 1, 2: 3, 3: 1, 4: 2}
+        {2: 3, 1: 1, 4: 2, 3: 1}
         sage: evaluation_dict('badbcdb')
-        {'a': 1, 'b': 3, 'c': 1, 'd': 2}
+        {'b': 3, 'a': 1, 'd': 2, 'c': 1}
         sage: evaluation_dict([])
         {}
 
diff --git a/src/sage/combinat/words/suffix_trees.py b/src/sage/combinat/words/suffix_trees.py
index 325c33220f..e85700c1d7 100644
--- a/src/sage/combinat/words/suffix_trees.py
+++ b/src/sage/combinat/words/suffix_trees.py
@@ -1654,7 +1654,12 @@ class DecoratedSuffixTree(ImplicitSuffixTree):
             sage: w = Word('abaababbabba')
             sage: T = DecoratedSuffixTree(w)
             sage: T._partial_labeling()
-            {(3, 4): [1], (5, 1): [3], (5, 6): [1], (11, 17): [1], (13, 8): [1], (15, 10): [2]}
+            {(3, 4): [1],
+             (5, 1): [3],
+             (5, 6): [1],
+             (15, 10): [2],
+             (13, 8): [1],
+             (11, 17): [1]}
         """
         def node_processing(node, parent, head):
             r"""
diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py
index 47327fab0c..3557ae6ca8 100644
--- a/src/sage/combinat/words/words.py
+++ b/src/sage/combinat/words/words.py
@@ -1668,8 +1668,8 @@ class FiniteOrInfiniteWords(AbstractLanguage):
         EXAMPLES::
 
             sage: Words('ab')._element_classes
-            {'iter': <class 'sage.combinat.words.word.Word_iter'>,
-             'iter_with_caching': <class 'sage.combinat.words.word.Word_iter_with_caching'>}
+            {'iter_with_caching': <class 'sage.combinat.words.word.Word_iter_with_caching'>,
+             'iter': <class 'sage.combinat.words.word.Word_iter'>}
         """
         import sage.combinat.words.word as word
         return {'iter_with_caching': word.Word_iter_with_caching,
diff --git a/src/sage/crypto/mq/sr.py b/src/sage/crypto/mq/sr.py
index 0124f776d0..5683ae819e 100644
--- a/src/sage/crypto/mq/sr.py
+++ b/src/sage/crypto/mq/sr.py
@@ -1654,49 +1654,49 @@ class SR_generic(MPolynomialSystemGenerator):
 
             sage: sr = mq.SR(1,1,1,4)
             sage: sr.variable_dict()
-            {'k000': k000,
-             'k001': k001,
-             'k002': k002,
-             'k003': k003,
-             'k100': k100,
+            {'k100': k100,
              'k101': k101,
              'k102': k102,
              'k103': k103,
-             's000': s000,
-             's001': s001,
-             's002': s002,
-             's003': s003,
+             'x100': x100,
+             'x101': x101,
+             'x102': x102,
+             'x103': x103,
              'w100': w100,
              'w101': w101,
              'w102': w102,
              'w103': w103,
-             'x100': x100,
-             'x101': x101,
-             'x102': x102,
-             'x103': x103}
+             's000': s000,
+             's001': s001,
+             's002': s002,
+             's003': s003,
+             'k000': k000,
+             'k001': k001,
+             'k002': k002,
+             'k003': k003}
 
             sage: sr = mq.SR(1,1,1,4,gf2=True)
             sage: sr.variable_dict()
-            {'k000': k000,
-             'k001': k001,
-             'k002': k002,
-             'k003': k003,
-             'k100': k100,
+            {'k100': k100,
              'k101': k101,
              'k102': k102,
              'k103': k103,
-             's000': s000,
-             's001': s001,
-             's002': s002,
-             's003': s003,
+             'x100': x100,
+             'x101': x101,
+             'x102': x102,
+             'x103': x103,
              'w100': w100,
              'w101': w101,
              'w102': w102,
              'w103': w103,
-             'x100': x100,
-             'x101': x101,
-             'x102': x102,
-             'x103': x103}
+             's000': s000,
+             's001': s001,
+             's002': s002,
+             's003': s003,
+             'k000': k000,
+             'k001': k001,
+             'k002': k002,
+             'k003': k003}
 
         """
         try:
diff --git a/src/sage/databases/sql_db.py b/src/sage/databases/sql_db.py
index c308d3ac68..50d43ab275 100644
--- a/src/sage/databases/sql_db.py
+++ b/src/sage/databases/sql_db.py
@@ -160,10 +160,10 @@ def verify_column(col_dict):
         sage: from sage.databases.sql_db import verify_column
         sage: col = {'sql':'BOOLEAN'}
         sage: verify_column(col)
-        {'index': False, 'primary_key': False, 'sql': 'BOOLEAN', 'unique': False}
+        {'primary_key': False, 'index': False, 'unique': False, 'sql': 'BOOLEAN'}
         sage: col = {'primary_key':True, 'sql':'INTEGER'}
         sage: verify_column(col)
-        {'index': True, 'primary_key': True, 'sql': 'INTEGER', 'unique': True}
+        {'primary_key': True, 'index': True, 'unique': True, 'sql': 'INTEGER'}
         sage: verify_column({})
         Traceback (most recent call last):
         ...
@@ -1799,14 +1799,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.create_table('simon', {'n':{'sql':'INTEGER', 'index':True}, 'n2':{'sql':'INTEGER'}})
             sage: MonicPolys.make_index('n2','simon')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'}}}
         """
         if self.__read_only__:
             raise RuntimeError('Cannot modify a read only database.')
@@ -1840,14 +1840,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.create_table('simon', {'n':{'sql':'INTEGER', 'index':True}, 'n2':{'sql':'INTEGER'}})
             sage: MonicPolys.drop_index('simon', 'n')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': False,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': False,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': False,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': False,
+               'index': False,
+               'unique': False,
+               'sql': 'INTEGER'}}}
         """
         if self.__read_only__:
             raise RuntimeError('Cannot modify a read only database.')
@@ -1881,14 +1881,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.create_table('simon', {'n':{'sql':'INTEGER', 'index':True}, 'n2':{'sql':'INTEGER'}})
             sage: MonicPolys.make_unique('simon', 'n2')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': False,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': True}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': False,
+               'index': False,
+               'unique': True,
+               'sql': 'INTEGER'}}}
 
         """
         if self.__read_only__:
@@ -1920,14 +1920,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.make_unique('simon', 'n2')
             sage: MonicPolys.drop_unique('simon', 'n2')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': False,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': False,
+               'index': False,
+               'unique': False,
+               'sql': 'INTEGER'}}}
         """
         if self.__read_only__:
             raise RuntimeError('Cannot modify a read only database.')
@@ -1963,14 +1963,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.create_table('simon', {'n':{'sql':'INTEGER', 'index':True}, 'n2':{'sql':'INTEGER'}})
             sage: MonicPolys.make_primary_key('simon', 'n2')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': False,
-               'primary_key': True,
-               'sql': 'INTEGER',
-               'unique': True}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': True,
+               'index': False,
+               'unique': True,
+               'sql': 'INTEGER'}}}
         """
         if self.__read_only__:
             raise RuntimeError('Cannot modify a read only database.')
@@ -2007,14 +2007,14 @@ class SQLDatabase(SageObject):
             sage: MonicPolys.make_primary_key('simon', 'n2')
             sage: MonicPolys.drop_primary_key('simon', 'n2')
             sage: MonicPolys.get_skeleton()
-            {'simon': {'n': {'index': True,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': False},
-              'n2': {'index': False,
-               'primary_key': False,
-               'sql': 'INTEGER',
-               'unique': True}}}
+            {'simon': {'n': {'primary_key': False,
+               'index': True,
+               'unique': False,
+               'sql': 'INTEGER'},
+              'n2': {'primary_key': False,
+               'index': False,
+               'unique': True,
+               'sql': 'INTEGER'}}}
         """
         if self.__read_only__:
             raise RuntimeError('Cannot modify a read only database.')
diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
index 7656a69ce0..d1e8bf7388 100644
--- a/src/sage/doctest/forker.py
+++ b/src/sage/doctest/forker.py
@@ -139,7 +139,7 @@ def init_sage():
     dictionary output::
 
         sage: {'a':23, 'b':34, 'au':56, 'bbf':234, 'aaa':234}
-        {'a': 23, 'aaa': 234, 'au': 56, 'b': 34, 'bbf': 234}
+        {'a': 23, 'b': 34, 'au': 56, 'bbf': 234, 'aaa': 234}
     """
     try:
         # We need to ensure that the Matplotlib font cache is built to
diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py
index f980982715..0b77d5d84d 100644
--- a/src/sage/doctest/util.py
+++ b/src/sage/doctest/util.py
@@ -78,7 +78,7 @@ def dict_difference(self, other):
         sage: D1 = DocTestDefaults()
         sage: D2 = DocTestDefaults(foobar="hello", timeout=100)
         sage: dict_difference(D2.__dict__, D1.__dict__)
-        {'foobar': 'hello', 'timeout': 100}
+        {'timeout': 100, 'foobar': 'hello'}
     """
     D = dict()
     for k, v in iteritems(self):
diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx
index 7c37796afb..cffcc02d46 100644
--- a/src/sage/ext/fast_callable.pyx
+++ b/src/sage/ext/fast_callable.pyx
@@ -2020,11 +2020,11 @@ cdef class InstructionStream:
             sage: instr_stream = InstructionStream(metadata, 1)
             sage: instr_stream.get_current()
             {'args': 1,
-             'code': [],
              'constants': [],
-             'domain': None,
              'py_constants': [],
-             'stack': 0}
+             'stack': 0,
+             'code': [],
+             'domain': None}
             sage: md = instr_stream.get_metadata()
             sage: type(md)
             <type 'sage.ext.fast_callable.InterpreterMetadata'>
@@ -2241,11 +2241,11 @@ cdef class InstructionStream:
             sage: instr_stream = InstructionStream(metadata, 1)
             sage: instr_stream.get_current()
             {'args': 1,
-             'code': [],
              'constants': [],
-             'domain': None,
              'py_constants': [],
-             'stack': 0}
+             'stack': 0,
+             'code': [],
+             'domain': None}
             sage: instr_stream.instr('load_arg', 0)
             sage: instr_stream.instr('py_call', math.sin, 1)
             sage: instr_stream.instr('abs')
@@ -2254,11 +2254,11 @@ cdef class InstructionStream:
             [('load_arg', 0), ('py_call', <built-in function sin>, 1), 'abs', 'return']
             sage: instr_stream.get_current()
             {'args': 1,
-             'code': [0, 0, 3, 0, 1, 12, 2],
              'constants': [],
-             'domain': None,
              'py_constants': [<built-in function sin>],
-             'stack': 1}
+             'stack': 1,
+             'code': [0, 0, 3, 0, 1, 12, 2],
+             'domain': None}
         """
         d = {'args': self._n_args,
              'constants': self._constants,
@@ -2438,11 +2438,11 @@ cdef class Wrapper:
             sage: v = Wrapper_py(instr_stream.get_current())
             sage: v.get_orig_args()
             {'args': 1,
-             'code': [0, 0, 1, 0, 4, 0, 0, 1, 1, 4, 6, 2],
              'constants': [pi, 1],
-             'domain': None,
              'py_constants': [],
-             'stack': 3}
+             'stack': 3,
+             'code': [0, 0, 1, 0, 4, 0, 0, 1, 1, 4, 6, 2],
+             'domain': None}
             sage: v.op_list()
             [('load_arg', 0), ('load_const', pi), 'add', ('load_arg', 0), ('load_const', 1), 'add', 'mul', 'return']
         """
@@ -2465,11 +2465,11 @@ cdef class Wrapper:
 
             sage: fast_callable(sin(x)/x, vars=[x], domain=RDF).get_orig_args()
             {'args': 1,
-             'code': [0, 0, 16, 0, 0, 8, 2],
              'constants': [],
-             'domain': Real Double Field,
              'py_constants': [],
-             'stack': 2}
+             'stack': 2,
+             'code': [0, 0, 16, 0, 0, 8, 2],
+             'domain': Real Double Field}
         """
         return self._orig_args
 
diff --git a/src/sage/geometry/polyhedron/ppl_lattice_polytope.py b/src/sage/geometry/polyhedron/ppl_lattice_polytope.py
index 4281de7bf0..8bc045a34b 100644
--- a/src/sage/geometry/polyhedron/ppl_lattice_polytope.py
+++ b/src/sage/geometry/polyhedron/ppl_lattice_polytope.py
@@ -1231,15 +1231,15 @@ class LatticePolytope_PPL_class(C_Polyhedron):
             sage: polygon.embed_in_reflexive_polytope('polytope')
             A 2-dimensional lattice polytope in ZZ^2 with 3 vertices
             sage: polygon.embed_in_reflexive_polytope('points')
-            {(0, 0, 2, 1): (1, 0),
-             (0, 1, 2, 0): (0, 1),
-             (1, 0, 1, 2): (2, 0),
-             (1, 1, 1, 1): (1, 1),
+            {(0, 1, 2, 0): (0, 1),
              (1, 2, 1, 0): (0, 2),
-             (2, 0, 0, 3): (3, 0),
-             (2, 1, 0, 2): (2, 1),
+             (2, 3, 0, 0): (0, 3),
+             (0, 0, 2, 1): (1, 0),
+             (1, 1, 1, 1): (1, 1),
              (2, 2, 0, 1): (1, 2),
-             (2, 3, 0, 0): (0, 3)}
+             (1, 0, 1, 2): (2, 0),
+             (2, 1, 0, 2): (2, 1),
+             (2, 0, 0, 3): (3, 0)}
 
             sage: LatticePolytope_PPL((0,0), (4,0), (0,4)).embed_in_reflexive_polytope()
             Traceback (most recent call last):
diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py
index a80d9111e4..5930fd9396 100644
--- a/src/sage/geometry/triangulation/element.py
+++ b/src/sage/geometry/triangulation/element.py
@@ -605,32 +605,32 @@ class Triangulation(Element):
 
             sage: triangulation = polytopes.hypercube(2).triangulate(engine='internal')
             sage: triangulation._boundary_simplex_dictionary()
-            {(0, 1): ((0, 1, 3),),
-             (0, 2): ((0, 2, 3),),
+            {(1, 3): ((0, 1, 3),),
              (0, 3): ((0, 1, 3), (0, 2, 3)),
-             (1, 3): ((0, 1, 3),),
-             (2, 3): ((0, 2, 3),)}
+             (0, 1): ((0, 1, 3),),
+             (2, 3): ((0, 2, 3),),
+             (0, 2): ((0, 2, 3),)}
 
             sage: triangulation = polytopes.cube().triangulate(engine='internal')
             sage: triangulation._boundary_simplex_dictionary()
-            {(0, 1, 2): ((0, 1, 2, 7),),
-             (0, 1, 4): ((0, 1, 4, 7),),
-             (0, 1, 7): ((0, 1, 2, 7), (0, 1, 4, 7)),
-             (0, 2, 4): ((0, 2, 4, 7),),
+            {(1, 2, 7): ((0, 1, 2, 7), (1, 2, 3, 7)),
              (0, 2, 7): ((0, 1, 2, 7), (0, 2, 4, 7)),
+             (0, 1, 7): ((0, 1, 2, 7), (0, 1, 4, 7)),
+             (0, 1, 2): ((0, 1, 2, 7),),
+             (1, 4, 7): ((0, 1, 4, 7), (1, 4, 5, 7)),
              (0, 4, 7): ((0, 1, 4, 7), (0, 2, 4, 7)),
-             (1, 2, 3): ((1, 2, 3, 7),),
-             (1, 2, 7): ((0, 1, 2, 7), (1, 2, 3, 7)),
+             (0, 1, 4): ((0, 1, 4, 7),),
+             (2, 4, 7): ((0, 2, 4, 7), (2, 4, 6, 7)),
+             (0, 2, 4): ((0, 2, 4, 7),),
+             (2, 3, 7): ((1, 2, 3, 7),),
              (1, 3, 7): ((1, 2, 3, 7),),
-             (1, 4, 5): ((1, 4, 5, 7),),
-             (1, 4, 7): ((0, 1, 4, 7), (1, 4, 5, 7)),
+             (1, 2, 3): ((1, 2, 3, 7),),
+             (4, 5, 7): ((1, 4, 5, 7),),
              (1, 5, 7): ((1, 4, 5, 7),),
-             (2, 3, 7): ((1, 2, 3, 7),),
-             (2, 4, 6): ((2, 4, 6, 7),),
-             (2, 4, 7): ((0, 2, 4, 7), (2, 4, 6, 7)),
+             (1, 4, 5): ((1, 4, 5, 7),),
+             (4, 6, 7): ((2, 4, 6, 7),),
              (2, 6, 7): ((2, 4, 6, 7),),
-             (4, 5, 7): ((1, 4, 5, 7),),
-             (4, 6, 7): ((2, 4, 6, 7),)}
+             (2, 4, 6): ((2, 4, 6, 7),)}
         """
         result = dict()
         for simplex in self:
diff --git a/src/sage/graphs/base/boost_graph.pyx b/src/sage/graphs/base/boost_graph.pyx
index 6ba0a44c9a..c50374c542 100644
--- a/src/sage/graphs/base/boost_graph.pyx
+++ b/src/sage/graphs/base/boost_graph.pyx
@@ -1137,10 +1137,10 @@ cpdef johnson_shortest_paths(g, weight_function=None, distances=True, predecesso
          3: {3: 0}}
         sage: g = DiGraph([(1,2,3),(2,3,2),(1,4,1),(4,2,1)], weighted=True)
         sage: johnson_shortest_paths(g, distances=False, predecessors=True)
-        {1: {1: None, 2: 4, 3: 2, 4: 1},
+        {1: {1: None, 4: 1, 3: 2, 2: 4},
          2: {2: None, 3: 2},
          3: {3: None},
-         4: {2: 4, 3: 2, 4: None}}
+         4: {4: None, 3: 2, 2: 4}}
 
     TESTS:
 
@@ -1292,10 +1292,10 @@ cpdef floyd_warshall_shortest_paths(g, weight_function=None, distances=True, pre
          3: {3: 0}}
         sage: g = DiGraph([(1,2,3),(2,3,2),(1,4,1),(4,2,1)], weighted=True)
         sage: floyd_warshall_shortest_paths(g, distances=False, predecessors=True)
-        {1: {1: None, 2: 4, 3: 2, 4: 1},
+        {1: {1: None, 4: 1, 3: 2, 2: 4},
          2: {2: None, 3: 2},
          3: {3: None},
-         4: {2: 4, 3: 2, 4: None}}
+         4: {4: None, 3: 2, 2: 4}}
 
     TESTS:
 
diff --git a/src/sage/graphs/base/c_graph.pyx b/src/sage/graphs/base/c_graph.pyx
index 59184ccc9f..04affd2261 100644
--- a/src/sage/graphs/base/c_graph.pyx
+++ b/src/sage/graphs/base/c_graph.pyx
@@ -2890,7 +2890,7 @@ cdef class CGraphBackend(GenericGraphBackend):
             sage: all((not paths[v] or len(paths[v])-1 == g.distance(0,v)) for v in g)
             True
             sage: g._backend.shortest_path_all_vertices(0, distance_flag=True)
-            {0: 0, 1: 1, 2: 2, 3: 2, 4: 1, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2}
+            {0: 0, 5: 1, 4: 1, 1: 1, 6: 2, 2: 2, 9: 2, 3: 2, 8: 2, 7: 2}
 
         On a disconnected graph ::
 
diff --git a/src/sage/graphs/centrality.pyx b/src/sage/graphs/centrality.pyx
index cd69e1628a..0dbe75cdad 100755
--- a/src/sage/graphs/centrality.pyx
+++ b/src/sage/graphs/centrality.pyx
@@ -854,7 +854,7 @@ def centrality_closeness_random_k(G, int k=1):
 
         sage: from sage.graphs.centrality import centrality_closeness_random_k
         sage: G = graphs.PetersenGraph()
-        sage: centrality_closeness_random_k(G, 10)
+        sage: centrality_closeness_random_k(G, 10) # random
         {0: 0.6,
          1: 0.6,
          2: 0.6,
diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py
index 3f13b3324f..d91600dc2e 100644
--- a/src/sage/graphs/digraph.py
+++ b/src/sage/graphs/digraph.py
@@ -2671,7 +2671,7 @@ class DiGraph(GenericGraph):
         installed, so we don't test its relative values::
 
             sage: H.layout_acyclic()
-            {0: [..., ...], 1: [..., ...], 2: [..., ...], 3: [..., ...], 5: [..., ...], 6: [..., ...]}
+            {0: [..., ...], 5: [..., ...], 1: [..., ...], 6: [..., ...], 2: [..., ...], 3: [..., ...]}
 
             sage: H = DiGraph({0: [1]})
             sage: pos = H.layout_acyclic(rankdir='up')
@@ -2716,15 +2716,15 @@ class DiGraph(GenericGraph):
 
             sage: H = DiGraph({0: [1, 2], 1: [3], 2: [3], 3: [], 5: [1, 6], 6: [2, 3]})
             sage: H.layout_acyclic_dummy()
-            {0: [1.00..., 0], 1: [1.00..., 1], 2: [1.51..., 2], 3: [1.50..., 3], 5: [2.01..., 0], 6: [2.00..., 1]}
+            {0: [1.00..., 0], 5: [2.01..., 0], 1: [1.00..., 1], 6: [2.00..., 1], 2: [1.51..., 2], 3: [1.50..., 3]}
 
             sage: H = DiGraph({0: [1]})
             sage: H.layout_acyclic_dummy(rankdir='up')
             {0: [0.5..., 0], 1: [0.5..., 1]}
             sage: H.layout_acyclic_dummy(rankdir='down')
-            {0: [0.5..., 1], 1: [0.5..., 0]}
+            {1: [0.5..., 0], 0: [0.5..., 1]}
             sage: H.layout_acyclic_dummy(rankdir='left')
-            {0: [1, 0.5...], 1: [0, 0.5...]}
+            {1: [0, 0.5...], 0: [1, 0.5...]}
             sage: H.layout_acyclic_dummy(rankdir='right')
             {0: [0, 0.5...], 1: [1, 0.5...]}
             sage: H = DiGraph({0: [1, 2], 1: [3], 2: [3], 3: [1], 5: [1, 6], 6: [2, 3]})
diff --git a/src/sage/graphs/distances_all_pairs.pyx b/src/sage/graphs/distances_all_pairs.pyx
index 463db9c7a2..c74d942165 100644
--- a/src/sage/graphs/distances_all_pairs.pyx
+++ b/src/sage/graphs/distances_all_pairs.pyx
@@ -1417,7 +1417,7 @@ def distances_distribution(G):
         sage: g = graphs.PetersenGraph()
         sage: g.add_edge('good','wine')
         sage: g.distances_distribution()
-        {1: 8/33, 2: 5/11, +Infinity: 10/33}
+        {1: 8/33, +Infinity: 10/33, 2: 5/11}
 
     The de Bruijn digraph dB(2,3)::
 
@@ -1542,9 +1542,9 @@ def floyd_warshall(gg, paths=True, distances=False):
         sage: g = graphs.DiamondGraph()
         sage: floyd_warshall(g, paths=False, distances=True)
         {0: {0: 0, 1: 1, 2: 1, 3: 2},
-         1: {0: 1, 1: 0, 2: 1, 3: 1},
-         2: {0: 1, 1: 1, 2: 0, 3: 1},
-         3: {0: 2, 1: 1, 2: 1, 3: 0}}
+         1: {1: 0, 0: 1, 2: 1, 3: 1},
+         2: {2: 0, 0: 1, 1: 1, 3: 1},
+         3: {3: 0, 0: 2, 1: 1, 2: 1}}
 
     TESTS:
 
diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
index 8b8c98cb15..6823e13b26 100644
--- a/src/sage/graphs/generic_graph.py
+++ b/src/sage/graphs/generic_graph.py
@@ -5155,7 +5155,7 @@ class GenericGraph(GenericGraph_pyx):
         This method is deprecated since Sage-4.4.1.alpha2. Please use instead:
 
             sage: g.layout(layout = "planar", save_pos = True)
-            {0: [0, 5], 1: [1, 4], 2: [5, 1], 3: [3, 1], 4: [1, 0], 5: [2, 1], 6: [1, 3]}
+            {2: [5, 1], 0: [0, 5], 4: [1, 0], 1: [1, 4], 3: [3, 1], 5: [2, 1], 6: [1, 3]}
         """
         deprecation(24494, 'This method is replaced by the method layout. '
                            'Please use layout(layout="planar", save_pos=True) '
@@ -5209,16 +5209,16 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: g = graphs.PathGraph(10)
             sage: g.layout(layout='planar', save_pos=True, test=True)
-            {0: [0, 8],
-             1: [6, 2],
-             2: [8, 1],
-             3: [6, 1],
-             4: [1, 0],
-             5: [5, 2],
-             6: [2, 2],
-             7: [2, 3],
-             8: [1, 5],
-             9: [2, 4]}
+            {2: [8, 1],
+             0: [0, 8],
+             4: [1, 0],
+             1: [6, 2],
+             3: [6, 1],
+             5: [5, 2],
+             6: [2, 2],
+             7: [2, 3],
+             8: [1, 5],
+             9: [2, 4]}
             sage: g = graphs.BalancedTree(3, 4)
             sage: pos = g.layout(layout='planar', save_pos=True, test=True)
             sage: pos[0]
@@ -5227,7 +5227,7 @@ class GenericGraph(GenericGraph_pyx):
             [93, 14]
             sage: g = graphs.CycleGraph(7)
             sage: g.layout(layout='planar', save_pos=True, test=True)
-            {0: [0, 5], 1: [1, 4], 2: [5, 1], 3: [3, 1], 4: [1, 0], 5: [2, 1], 6: [1, 3]}
+            {2: [5, 1], 0: [0, 5], 4: [1, 0], 1: [1, 4], 3: [3, 1], 5: [2, 1], 6: [1, 3]}
             sage: g = graphs.CompleteGraph(5)
             sage: g.layout(layout='planar', save_pos=True, test=True, set_embedding=True)
             Traceback (most recent call last):
@@ -5238,9 +5238,9 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: g = graphs.CompleteGraph(4)
             sage: g.layout(layout='planar', external_face=(0,1))
-            {0: [0, 2], 1: [2, 1], 2: [1, 0], 3: [1, 1]}
+            {1: [2, 1], 0: [0, 2], 2: [1, 0], 3: [1, 1]}
             sage: g.layout(layout='planar', external_face=(3,1))
-            {0: [2, 1], 1: [0, 2], 2: [1, 1], 3: [1, 0]}
+            {0: [2, 1], 1: [0, 2], 3: [1, 0], 2: [1, 1]}
 
         TESTS::
 
@@ -16571,7 +16571,7 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: D = graphs.DodecahedralGraph()
             sage: D.shortest_paths(0)
-            {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 19, 3], 4: [0, 19, 3, 4], 5: [0, 1, 2, 6, 5], 6: [0, 1, 2, 6], 7: [0, 1, 8, 7], 8: [0, 1, 8], 9: [0, 10, 9], 10: [0, 10], 11: [0, 10, 11], 12: [0, 10, 11, 12], 13: [0, 10, 9, 13], 14: [0, 1, 8, 7, 14], 15: [0, 19, 18, 17, 16, 15], 16: [0, 19, 18, 17, 16], 17: [0, 19, 18, 17], 18: [0, 19, 18], 19: [0, 19]}
+            {0: [0], 10: [0, 10], 19: [0, 19], 1: [0, 1], 8: [0, 1, 8], 2: [0, 1, 2], 3: [0, 19, 3], 18: [0, 19, 18], 11: [0, 10, 11], 9: [0, 10, 9], 13: [0, 10, 9, 13], 12: [0, 10, 11, 12], 17: [0, 19, 18, 17], 4: [0, 19, 3, 4], 6: [0, 1, 2, 6], 7: [0, 1, 8, 7], 14: [0, 1, 8, 7, 14], 5: [0, 1, 2, 6, 5], 16: [0, 19, 18, 17, 16], 15: [0, 19, 18, 17, 16, 15]}
 
         All these paths are obviously induced graphs::
 
@@ -16581,7 +16581,7 @@ class GenericGraph(GenericGraph_pyx):
         ::
 
             sage: D.shortest_paths(0, cutoff=2)
-            {0: [0], 1: [0, 1], 2: [0, 1, 2], 3: [0, 19, 3], 8: [0, 1, 8], 9: [0, 10, 9], 10: [0, 10], 11: [0, 10, 11], 18: [0, 19, 18], 19: [0, 19]}
+            {0: [0], 10: [0, 10], 19: [0, 19], 1: [0, 1], 8: [0, 1, 8], 2: [0, 1, 2], 3: [0, 19, 3], 18: [0, 19, 18], 11: [0, 10, 11], 9: [0, 10, 9]}
             sage: G = Graph( { 0: {1: 1}, 1: {2: 1}, 2: {3: 1}, 3: {4: 2}, 4: {0: 2} }, sparse=True)
             sage: G.plot(edge_labels=True).show() # long time
             sage: G.shortest_paths(0, by_weight=True)
@@ -16591,7 +16591,7 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: D = DiGraph([(0,1,1),(1,2,3),(0,2,5)])
             sage: D.shortest_paths(0)
-            {0: [0], 1: [0, 1], 2: [0, 2]}
+            {0: [0], 2: [0, 2], 1: [0, 1]}
             sage: D.shortest_paths(0, by_weight=True)
             {0: [0], 1: [0, 1], 2: [0, 1, 2]}
 
@@ -16840,7 +16840,7 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: D = graphs.DodecahedralGraph()
             sage: D.shortest_path_lengths(0)
-            {0: 0, 1: 1, 2: 2, 3: 2, 4: 3, 5: 4, 6: 3, 7: 3, 8: 2, 9: 2, 10: 1, 11: 2, 12: 3, 13: 3, 14: 4, 15: 5, 16: 4, 17: 3, 18: 2, 19: 1}
+            {0: 0, 10: 1, 19: 1, 1: 1, 8: 2, 2: 2, 3: 2, 18: 2, 11: 2, 9: 2, 13: 3, 12: 3, 17: 3, 4: 3, 6: 3, 7: 3, 14: 4, 5: 4, 16: 4, 15: 5}
 
         Weighted case::
 
@@ -18924,18 +18924,18 @@ class GenericGraph(GenericGraph_pyx):
              '#00ff00': [((1,3,2,4), (1,4)(2,3), 3), ...],
              '#ff0000': [((1,3,2,4), (1,3)(2,4), 1), ...]}
             sage: G._color_by_label()  # py3
-            {'#0000ff': [((), (1,2), 1), ...],
-             '#00ff00': [((), (3,4), 3), ...],
-             '#ff0000': [((), (2,3), 2), ...]}
+            {'#ff0000': [((), (2,3), 2), ...],
+             '#00ff00': [((), (3,4), 3), ...],
+             '#0000ff': [((), (1,2), 1), ...]}
 
             sage: G._color_by_label({1: "blue", 2: "red", 3: "green"})  # py2
             {'blue': [((1,3,2,4), (1,3)(2,4), 1), ...],
              'green': [((1,3,2,4), (1,4)(2,3), 3), ...],
              'red': [((1,3,2,4), (1,2,4), 2), ...]}
             sage: G._color_by_label({1: "blue", 2: "red", 3: "green"})  # py3
-            {'blue': [((), (1,2), 1), ...],
-             'green': [((), (3,4), 3), ...],
-             'red': [((), (2,3), 2), ...]}
+            {'red': [((), (2,3), 2), ...],
+             'green': [((), (3,4), 3), ...],
+             'blue': [((), (1,2), 1), ...]}
 
         TESTS:
 
@@ -19080,8 +19080,8 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: g.layout(layout="acyclic_dummy", save_pos=True)
             {('0', 0): [0.3..., 0],
-             ('0', 1): [0.3..., 1],
              ('1', 0): [0.6..., 0],
+             ('0', 1): [0.3..., 1],
              ('1', 1): [0.6..., 1]}
 
             sage: D3 = g.layout(dim=3); D3  # random
@@ -19217,10 +19217,10 @@ class GenericGraph(GenericGraph_pyx):
             sage: g = graphs.LadderGraph(3)
             sage: g.layout_ranked(heights={i: (i, i+3) for i in range(3)})
             {0: [0.668..., 0],
-             1: [0.667..., 1],
-             2: [0.677..., 2],
              3: [1.34..., 0],
+             1: [0.667..., 1],
              4: [1.33..., 1],
+             2: [0.677..., 2],
              5: [1.33..., 2]}
             sage: g = graphs.LadderGraph(7)
             sage: g.plot(layout="ranked", heights={i: (i, i+7) for i in range(7)})
@@ -19404,13 +19404,13 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: G = graphs.BalancedTree(2, 2)
             sage: G.layout_tree(tree_root=0)
-            {0: (1.5, 0),
-             1: (2.5, -1),
+            {6: (0.0, -2),
+             5: (1.0, -2),
              2: (0.5, -1),
-             3: (3.0, -2),
              4: (2.0, -2),
-             5: (1.0, -2),
-             6: (0.0, -2)}
+             3: (3.0, -2),
+             1: (2.5, -1),
+             0: (1.5, 0)}
 
             sage: G = graphs.BalancedTree(2, 4)
             sage: G.plot(layout="tree", tree_root=0, tree_orientation="up")
@@ -19422,15 +19422,15 @@ class GenericGraph(GenericGraph_pyx):
             sage: T.set_embedding({0: [1, 6, 3], 1: [2, 5, 0], 2: [1], 3: [4, 7, 8, 0],
             ....:     4: [3], 5: [1], 6: [0], 7: [3], 8: [3]})
             sage: T.layout_tree()
-            {0: (2.166..., 0),
-             1: (3.5, -1),
-             2: (4.0, -2),
-             3: (1.0, -1),
+            {8: (0.0, -2),
+             7: (1.0, -2),
              4: (2.0, -2),
-             5: (3.0, -2),
+             3: (1.0, -1),
              6: (2.0, -1),
-             7: (1.0, -2),
-             8: (0.0, -2)}
+             5: (3.0, -2),
+             2: (4.0, -2),
+             1: (3.5, -1),
+             0: (2.166..., 0)}
             sage: T.plot(layout="tree", tree_root=3)
             Graphics object consisting of 18 graphics primitives
 
@@ -23589,7 +23589,8 @@ class GenericGraph(GenericGraph_pyx):
 
             sage: G = DiGraph({1: [10], 2:[10,11], 3:[10,11], 4:[], 5:[11, 4], 6:[11], 7:[10,11], 8:[10,11], 9:[10], 10:[11, 5, 8], 11:[6]})
             sage: G.katz_centrality(.85)
-            {1: 0.000000000000000,
+            {10: 20.9819819819820,
+             1: 0.000000000000000,
              2: 0.000000000000000,
              3: 0.000000000000000,
              4: 16.7319819819820,
@@ -23598,7 +23598,6 @@ class GenericGraph(GenericGraph_pyx):
              7: 0.000000000000000,
              8: 18.6846846846847,
              9: 0.000000000000000,
-             10: 20.9819819819820,
              11: 202.778914049184}
 
 
@@ -23618,7 +23618,7 @@ class GenericGraph(GenericGraph_pyx):
             sage: graphs.PathGraph(4).katz_centrality(1/20,3)
             21/379
             sage: (graphs.PathGraph(3) + graphs.PathGraph(4)).katz_centrality(1/20)
-            {0: 11/199, 1: 21/199, 2: 11/199, 3: 21/379, 4: 41/379, 5: 41/379, 6: 21/379}
+            {3: 21/379, 4: 41/379, 5: 41/379, 6: 21/379, 0: 11/199, 1: 21/199, 2: 11/199}
 
         """
         n = self.order()
diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py
index bcb9ff1be6..4d0c5ce933 100644
--- a/src/sage/graphs/graph.py
+++ b/src/sage/graphs/graph.py
@@ -3814,7 +3814,7 @@ class Graph(GenericGraph):
         EXAMPLES::
 
             sage: graphs.CycleGraph(4).bipartite_color()
-            {0: 1, 1: 0, 2: 1, 3: 0}
+            {0: 1, 1: 0, 3: 0, 2: 1}
             sage: graphs.CycleGraph(5).bipartite_color()
             Traceback (most recent call last):
             ...
@@ -4097,10 +4097,10 @@ class Graph(GenericGraph):
             sage: G.plot(partition=P)
             Graphics object consisting of 16 graphics primitives
             sage: G.coloring(hex_colors=True, algorithm="MILP")
-            {'#0000ff': [4], '#00ff00': [0, 6, 5], '#ff0000': [2, 1, 3]}
+            {'#ff0000': [2, 1, 3], '#00ff00': [0, 6, 5], '#0000ff': [4]}
             sage: H = G.coloring(hex_colors=True, algorithm="DLX")
             sage: H
-            {'#0000ff': [4], '#00ff00': [1, 2, 3], '#ff0000': [0, 5, 6]}
+            {'#ff0000': [0, 5, 6], '#00ff00': [1, 2, 3], '#0000ff': [4]}
             sage: G.plot(vertex_colors=H)
             Graphics object consisting of 16 graphics primitives
 
diff --git a/src/sage/graphs/graph_coloring.pyx b/src/sage/graphs/graph_coloring.pyx
index 47b93c1f38..7493fd8dd1 100644
--- a/src/sage/graphs/graph_coloring.pyx
+++ b/src/sage/graphs/graph_coloring.pyx
@@ -1029,10 +1029,10 @@ def edge_coloring(g, value_only=False, vizing=False, hex_colors=False, solver=No
         [(0, 5), (2, 7)],
         [(1, 6), (3, 4), (5, 8), (7, 9)]]
        sage: edge_coloring(g, value_only=False, hex_colors=True, solver='GLPK')
-       {'#00ffff': [(0, 5), (2, 7)],
-        '#7f00ff': [(1, 6), (3, 4), (5, 8), (7, 9)],
+       {'#ff0000': [(0, 1), (2, 3), (4, 9), (5, 7), (6, 8)],
         '#7fff00': [(0, 4), (1, 2), (3, 8), (6, 9)],
-        '#ff0000': [(0, 1), (2, 3), (4, 9), (5, 7), (6, 8)]}
+        '#00ffff': [(0, 5), (2, 7)],
+        '#7f00ff': [(1, 6), (3, 4), (5, 8), (7, 9)]}
 
     Complete graphs are colored using the linear-time round-robin coloring::
 
diff --git a/src/sage/graphs/graph_database.py b/src/sage/graphs/graph_database.py
index c0a182bd41..ff728231e3 100644
--- a/src/sage/graphs/graph_database.py
+++ b/src/sage/graphs/graph_database.py
@@ -742,177 +742,177 @@ class GraphDatabase(SQLDatabase):
 
             sage: G = GraphDatabase()
             sage: G.get_skeleton()
-            {u'aut_grp': {u'aut_grp_size': {'index': True,
+            {'degrees': {'graph_id': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': False,
                'unique': False},
-              u'edge_transitive': {'index': True,
+              'degree_sequence': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'BOOLEAN',
+               'index': False,
                'unique': False},
-              u'graph_id': {'index': False,
+              'min_degree': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'num_fixed_points': {'index': True,
+              'max_degree': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'num_orbits': {'index': True,
+              'average_degree': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'vertex_transitive': {'index': True,
+              'degrees_sd': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'BOOLEAN',
-               'unique': False}},
-             u'degrees': {u'average_degree': {'index': True,
-               'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'degree_sequence': {'index': False,
+              'regular': {'sql': 'BOOLEAN',
+               'primary_key': False,
+               'index': True,
+               'unique': False}},
+             'spectrum': {'graph_id': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': False,
                'unique': False},
-              u'degrees_sd': {'index': True,
+              'spectrum': {'sql': 'TEXT',
                'primary_key': False,
-               'sql': u'REAL',
+               'index': False,
                'unique': False},
-              u'graph_id': {'index': False,
+              'min_eigenvalue': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'max_degree': {'index': True,
+              'max_eigenvalue': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'min_degree': {'index': True,
+              'eigenvalues_sd': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'regular': {'index': True,
+              'energy': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'BOOLEAN',
+               'index': True,
                'unique': False}},
-             u'graph_data': {u'complement_graph6': {'index': True,
+             'aut_grp': {'graph_id': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'TEXT',
+               'index': False,
                'unique': False},
-              u'eulerian': {'index': True,
+              'aut_grp_size': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'BOOLEAN',
+               'index': True,
                'unique': False},
-              u'graph6': {'index': True,
+              'num_orbits': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'TEXT',
+               'index': True,
                'unique': False},
-              u'graph_id': {'index': True,
+              'num_fixed_points': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
-               'unique': True},
-              u'lovasz_number': {'index': True,
-               'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'num_cycles': {'index': True,
+              'vertex_transitive': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'num_edges': {'index': True,
+              'edge_transitive': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'INTEGER',
-               'unique': False},
-              u'num_hamiltonian_cycles': {'index': True,
+               'index': True,
+               'unique': False}},
+             'misc': {'graph_id': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': False,
                'unique': False},
-              u'num_vertices': {'index': True,
+              'vertex_connectivity': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'perfect': {'index': True,
+              'edge_connectivity': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'BOOLEAN',
+               'index': True,
                'unique': False},
-              u'planar': {'index': True,
+              'num_components': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'BOOLEAN',
-               'unique': False}},
-             u'misc': {u'clique_number': {'index': True,
-               'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'diameter': {'index': True,
+              'girth': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'edge_connectivity': {'index': True,
+              'radius': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'BOOLEAN',
+               'index': True,
                'unique': False},
-              u'girth': {'index': True,
+              'diameter': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'graph_id': {'index': False,
+              'clique_number': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'independence_number': {'index': True,
+              'independence_number': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'induced_subgraphs': {'index': True,
+              'num_cut_vertices': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'TEXT',
+               'index': True,
                'unique': False},
-              u'min_vertex_cover_size': {'index': True,
+              'min_vertex_cover_size': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'num_components': {'index': True,
+              'num_spanning_trees': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'num_cut_vertices': {'index': True,
+              'induced_subgraphs': {'sql': 'TEXT',
+               'primary_key': False,
+               'index': True,
+               'unique': False}},
+             'graph_data': {'graph_id': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
+               'unique': True},
+              'graph6': {'sql': 'TEXT',
+               'primary_key': False,
+               'index': True,
                'unique': False},
-              u'num_spanning_trees': {'index': True,
+              'num_vertices': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'radius': {'index': True,
+              'num_edges': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'vertex_connectivity': {'index': True,
+              'num_cycles': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'BOOLEAN',
-               'unique': False}},
-             u'spectrum': {u'eigenvalues_sd': {'index': True,
+               'index': True,
+               'unique': False},
+              'num_hamiltonian_cycles': {'sql': 'INTEGER',
                'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'energy': {'index': True,
+              'eulerian': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'graph_id': {'index': False,
+              'planar': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'INTEGER',
+               'index': True,
                'unique': False},
-              u'max_eigenvalue': {'index': True,
+              'perfect': {'sql': 'BOOLEAN',
                'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'min_eigenvalue': {'index': True,
+              'lovasz_number': {'sql': 'REAL',
                'primary_key': False,
-               'sql': u'REAL',
+               'index': True,
                'unique': False},
-              u'spectrum': {'index': False,
+              'complement_graph6': {'sql': 'TEXT',
                'primary_key': False,
-               'sql': u'TEXT',
+               'index': True,
                'unique': False}}}
         """
         SQLDatabase.__init__(self, dblocation)
diff --git a/src/sage/graphs/isgci.py b/src/sage/graphs/isgci.py
index 9cd43d11b4..10ae7c9731 100644
--- a/src/sage/graphs/isgci.py
+++ b/src/sage/graphs/isgci.py
@@ -761,7 +761,7 @@ class GraphClasses(UniqueRepresentation):
             sage: type(t)
             <... 'list'>
             sage: t[0]
-            {'sub': 'gc_1', 'super': 'gc_2'}
+            {'super': 'gc_2', 'sub': 'gc_1'}
         """
         self._get_ISGCI()
         return self.inclusions()
@@ -778,12 +778,12 @@ class GraphClasses(UniqueRepresentation):
 
             sage: t = graph_classes.smallgraphs()
             sage: t
-            {'2C_4': Graph on 8 vertices,
-             '2K_2': Graph on 4 vertices,
-             '2K_3': Graph on 6 vertices,
-             '2K_3 + e': Graph on 6 vertices,
-             '2K_4': Graph on 8 vertices,
-             '2P_3': Graph on 6 vertices,
+            {'A \\cup K_1': Graph on 7 vertices,
+             '\\co{A \\cup K_1}': Graph on 7 vertices,
+             'gem \\cup K_1': Graph on 6 vertices,
+             '\\co{gem \\cup K_1}': Graph on 6 vertices,
+             'co-fork \\cup K_1': Graph on 6 vertices,
+             '\\co{co-fork \\cup K_1}': Graph on 6 vertices,
             ...
             sage: t['fish']
             Graph on 6 vertices
diff --git a/src/sage/graphs/partial_cube.py b/src/sage/graphs/partial_cube.py
index 7174a23662..fba9755ff2 100644
--- a/src/sage/graphs/partial_cube.py
+++ b/src/sage/graphs/partial_cube.py
@@ -110,7 +110,7 @@ def breadth_first_level_search(G, start):
     EXAMPLES::
 
         sage: H = digraphs.DeBruijn(3,2)
-        sage: list(sage.graphs.partial_cube.breadth_first_level_search(H, '00'))
+        sage: list(sage.graphs.partial_cube.breadth_first_level_search(H, '00')) # random
         [{'00': {'01', '02'}},
          {'01': {'10', '11', '12'}, '02': {'20', '21', '22'}},
          {'10': set(),
diff --git a/src/sage/graphs/schnyder.py b/src/sage/graphs/schnyder.py
index 241288a4de..391317fae5 100644
--- a/src/sage/graphs/schnyder.py
+++ b/src/sage/graphs/schnyder.py
@@ -473,7 +473,7 @@ def _compute_coordinates(g, x):
         sage: r = _realizer(g, tn)
         sage: _compute_coordinates(g,r)
         sage: g.get_pos()
-        {0: [0, 5], 1: [5, 1], 2: [1, 0], 3: [2, 1], 4: [1, 3], 5: [2, 2], 6: [4, 1]}
+        {1: [5, 1], 0: [0, 5], 2: [1, 0], 3: [2, 1], 4: [1, 3], 5: [2, 2], 6: [4, 1]}
     """
 
     tree_nodes, (v1, v2, v3) = x
diff --git a/src/sage/graphs/tutte_polynomial.py b/src/sage/graphs/tutte_polynomial.py
index 994ed72149..e6e7c50dae 100644
--- a/src/sage/graphs/tutte_polynomial.py
+++ b/src/sage/graphs/tutte_polynomial.py
@@ -389,7 +389,7 @@ class VertexOrder(EdgeSelection):
             sage: A.order
             [4, 6, 3, 2, 1, 7]
             sage: A.inverse_order
-            {1: 4, 2: 3, 3: 2, 4: 0, 6: 1, 7: 5}
+            {4: 0, 6: 1, 3: 2, 2: 3, 1: 4, 7: 5}
         """
         self.order = list(order)
         self.inverse_order = dict([reversed(_) for _ in enumerate(order)])
diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py
index 78602206c2..74cdb272d9 100644
--- a/src/sage/groups/perm_gps/cubegroup.py
+++ b/src/sage/groups/perm_gps/cubegroup.py
@@ -691,12 +691,12 @@ class CubeGroup(PermutationGroup_generic):
             sage: C.parse(facets) == g
             True
             sage: faces = C.faces("L"); faces
-            {'back': [[33, 34, 6], [36, 0, 4], [38, 39, 1]],
+            {'right': [[25, 26, 27], [28, 0, 29], [30, 31, 32]],
+             'left': [[11, 13, 16], [10, 0, 15], [9, 12, 14]],
+             'up': [[17, 2, 3], [20, 0, 5], [22, 7, 8]],
              'down': [[40, 42, 43], [37, 0, 45], [35, 47, 48]],
              'front': [[41, 18, 19], [44, 0, 21], [46, 23, 24]],
-             'left': [[11, 13, 16], [10, 0, 15], [9, 12, 14]],
-             'right': [[25, 26, 27], [28, 0, 29], [30, 31, 32]],
-             'up': [[17, 2, 3], [20, 0, 5], [22, 7, 8]]}
+             'back': [[33, 34, 6], [36, 0, 4], [38, 39, 1]]}
             sage: C.parse(faces) == C.parse("L")
             True
             sage: C.parse("L' R2") == C.parse("L^(-1)*R^2")
diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py
index 36ddf4df38..16d75bf9cd 100644
--- a/src/sage/knots/link.py
+++ b/src/sage/knots/link.py
@@ -753,47 +753,47 @@ class Link(SageObject):
             sage: L = Link([[1, 3, 2, 4], [2, 3, 1, 4]])
             sage: tails, heads = L._directions_of_edges()
             sage: tails
-            {1: [2, 3, 1, 4], 2: [1, 3, 2, 4], 3: [1, 3, 2, 4], 4: [2, 3, 1, 4]}
+            {2: [1, 3, 2, 4], 1: [2, 3, 1, 4], 3: [1, 3, 2, 4], 4: [2, 3, 1, 4]}
             sage: heads
-            {1: [1, 3, 2, 4], 2: [2, 3, 1, 4], 3: [2, 3, 1, 4], 4: [1, 3, 2, 4]}
+            {2: [2, 3, 1, 4], 1: [1, 3, 2, 4], 3: [2, 3, 1, 4], 4: [1, 3, 2, 4]}
 
         ::
 
             sage: L = Link([[1,5,2,4], [5,3,6,2], [3,1,4,6]])
             sage: tails, heads = L._directions_of_edges()
             sage: tails
-            {1: [3, 1, 4, 6],
-             2: [1, 5, 2, 4],
+            {2: [1, 5, 2, 4],
              3: [5, 3, 6, 2],
              4: [3, 1, 4, 6],
              5: [1, 5, 2, 4],
-             6: [5, 3, 6, 2]}
+             6: [5, 3, 6, 2],
+             1: [3, 1, 4, 6]}
             sage: heads
-            {1: [1, 5, 2, 4],
-             2: [5, 3, 6, 2],
+            {2: [5, 3, 6, 2],
              3: [3, 1, 4, 6],
              4: [1, 5, 2, 4],
              5: [5, 3, 6, 2],
-             6: [3, 1, 4, 6]}
+             6: [3, 1, 4, 6],
+             1: [1, 5, 2, 4]}
 
         ::
 
             sage: L = Link([[1,2,3,3], [2,4,5,5], [4,1,7,7]])
             sage: tails, heads = L._directions_of_edges()
             sage: tails
-            {1: [4, 1, 7, 7],
+            {3: [1, 2, 3, 3],
              2: [1, 2, 3, 3],
-             3: [1, 2, 3, 3],
-             4: [2, 4, 5, 5],
              5: [2, 4, 5, 5],
-             7: [4, 1, 7, 7]}
+             4: [2, 4, 5, 5],
+             7: [4, 1, 7, 7],
+             1: [4, 1, 7, 7]}
             sage: heads
-            {1: [1, 2, 3, 3],
+            {3: [1, 2, 3, 3],
              2: [2, 4, 5, 5],
-             3: [1, 2, 3, 3],
-             4: [4, 1, 7, 7],
              5: [2, 4, 5, 5],
-             7: [4, 1, 7, 7]}
+             4: [4, 1, 7, 7],
+             7: [4, 1, 7, 7],
+             1: [1, 2, 3, 3]}
         """
         tails = {}
         heads = {}
diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
index 26fb45b45d..35e16ab81d 100644
--- a/src/sage/libs/gap/element.pyx
+++ b/src/sage/libs/gap/element.pyx
@@ -3109,7 +3109,7 @@ cdef class GapElement_Record(GapElement):
     We can easily convert a Gap ``rec`` object into a Python ``dict``::
 
         sage: dict(rec)
-        {'a': 123, 'b': 456}
+        {'b': 456, 'a': 123}
         sage: type(_)
         <... 'dict'>
 
@@ -3217,15 +3217,15 @@ cdef class GapElement_Record(GapElement):
         EXAMPLES::
 
             sage: libgap.eval('rec(a:=1, b:=2)').sage()
-            {'a': 1, 'b': 2}
+            {'b': 2, 'a': 1}
             sage: all( isinstance(key,str) and val in ZZ for key,val in _.items() )
             True
 
             sage: rec = libgap.eval('rec(a:=123, b:=456, Sym3:=SymmetricGroup(3))')
             sage: rec.sage()
-            {'Sym3': NotImplementedError('cannot construct equivalent Sage object'...),
+            {'b': 456,
              'a': 123,
-             'b': 456}
+             'Sym3': NotImplementedError('cannot construct equivalent Sage object')}
         """
         result = {}
         for key, val in self:
@@ -3254,7 +3254,7 @@ cdef class GapElement_RecordIterator(object):
         sage: sorted(rec)
         [('a', 123), ('b', 456)]
         sage: dict(rec)
-        {'a': 123, 'b': 456}
+        {'b': 456, 'a': 123}
     """
 
     def __cinit__(self, rec):
diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
index b492ff467b..ebae8a34c4 100644
--- a/src/sage/libs/gap/libgap.pyx
+++ b/src/sage/libs/gap/libgap.pyx
@@ -119,7 +119,7 @@ Or get them as results of computations::
     sage: rec['Sym3']
     Sym( [ 1 .. 3 ] )
     sage: dict(rec)
-    {'Sym3': Sym( [ 1 .. 3 ] ), 'a': 123, 'b': 456}
+    {'b': 456, 'a': 123, 'Sym3': Sym( [ 1 .. 3 ] )}
 
 The output is a Sage dictionary whose keys are Sage strings and whose
 Values are instances of :meth:`~sage.libs.gap.element.GapElement`. So,
@@ -128,9 +128,9 @@ convert the entries into Sage objects, you should use the
 :meth:`~sage.libs.gap.element.GapElement.sage` method::
 
     sage: rec.sage()
-    {'Sym3': NotImplementedError('cannot construct equivalent Sage object'...),
+    {'b': 456,
      'a': 123,
-     'b': 456}
+     'Sym3': NotImplementedError('cannot construct equivalent Sage object')}
 
 Now ``rec['a']`` is a Sage integer. We have not implemented the
 conversion of the GAP symmetric group to the Sage symmetric group yet,
diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.pyx
index 1cf67dc15a..a3233c78cc 100644
--- a/src/sage/libs/lrcalc/lrcalc.pyx
+++ b/src/sage/libs/lrcalc/lrcalc.pyx
@@ -27,19 +27,19 @@ Compute a product of Schur functions; return the coefficients in the
 Schur expansion::
 
     sage: lrcalc.mult([2,1], [2,1])
-    {[2, 2, 1, 1]: 1,
+    {[3, 3]: 1,
+     [4, 2]: 1,
+     [2, 2, 1, 1]: 1,
      [2, 2, 2]: 1,
-     [3, 1, 1, 1]: 1,
      [3, 2, 1]: 2,
-     [3, 3]: 1,
      [4, 1, 1]: 1,
-     [4, 2]: 1}
+     [3, 1, 1, 1]: 1}
 
 Same product, but include only partitions with at most 3 rows.  This
 corresponds to computing in the representation ring of gl(3)::
 
     sage: lrcalc.mult([2,1], [2,1], 3)
-    {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
+    {[3, 3]: 1, [4, 2]: 1, [2, 2, 2]: 1, [3, 2, 1]: 2, [4, 1, 1]: 1}
 
 We can also compute the fusion product, here for sl(3) and level 2::
 
@@ -49,38 +49,38 @@ We can also compute the fusion product, here for sl(3) and level 2::
 Compute the expansion of a skew Schur function::
 
     sage: lrcalc.skew([3,2,1],[2,1])
-    {[1, 1, 1]: 1, [2, 1]: 2, [3]: 1}
+    {[3]: 1, [2, 1]: 2, [1, 1, 1]: 1}
 
 Compute the coproduct of a Schur function::
 
     sage: lrcalc.coprod([3,2,1])
-    {([1, 1, 1], [2, 1]): 1,
-     ([2, 1], [2, 1]): 2,
-     ([2, 1], [3]): 1,
-     ([2, 1, 1], [1, 1]): 1,
-     ([2, 1, 1], [2]): 1,
+    {([3, 1], [2]): 1,
      ([2, 2], [1, 1]): 1,
-     ([2, 2], [2]): 1,
-     ([2, 2, 1], [1]): 1,
      ([3, 1], [1, 1]): 1,
-     ([3, 1], [2]): 1,
-     ([3, 1, 1], [1]): 1,
+     ([2, 1], [3]): 1,
+     ([2, 1], [2, 1]): 2,
+     ([2, 2, 1], [1]): 1,
+     ([3, 2, 1], []): 1,
      ([3, 2], [1]): 1,
-     ([3, 2, 1], []): 1}
+     ([2, 1, 1], [2]): 1,
+     ([3, 1, 1], [1]): 1,
+     ([1, 1, 1], [2, 1]): 1,
+     ([2, 1, 1], [1, 1]): 1,
+     ([2, 2], [2]): 1}
 
 Multiply two Schubert polynomials::
 
     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3])
-    {[4, 5, 1, 3, 2]: 1,
+    {[5, 4, 1, 2, 3]: 1,
+     [4, 5, 1, 3, 2]: 1,
      [5, 3, 1, 4, 2]: 1,
-     [5, 4, 1, 2, 3]: 1,
      [6, 2, 1, 4, 3, 5]: 1}
 
 Same product, but include only permutations of 5 elements in the result.
 This corresponds to computing in the cohomology ring of Fl(5)::
 
     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-    {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
+    {[5, 4, 1, 2, 3]: 1, [4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1}
 
 List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
 this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
@@ -485,7 +485,7 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
         sage: mult([2,1],[3,2,1],3)
         {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
         sage: mult([2,1],[2,1],3,3)
-        {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1}
+        {[3, 3]: 1, [2, 2, 2]: 1, [3, 2, 1]: 2, [4, 1, 1]: 1}
         sage: mult([2,1],[2,1],None,3)
         Traceback (most recent call last):
         ...
diff --git a/src/sage/libs/ppl.pyx b/src/sage/libs/ppl.pyx
index 3bcf99b09a..22c2aec42a 100644
--- a/src/sage/libs/ppl.pyx
+++ b/src/sage/libs/ppl.pyx
@@ -2013,10 +2013,10 @@ cdef class Polyhedron(_mutable_or_immutable):
             sage: p = C_Polyhedron(cs)
             sage: p.maximize( x+y )
             {'bounded': True,
-             'generator': point(10/3, 0/3),
-             'maximum': True,
+             'sup_n': 10,
              'sup_d': 3,
-             'sup_n': 10}
+             'maximum': True,
+             'generator': point(10/3, 0/3)}
 
         Unbounded case::
 
@@ -2027,10 +2027,10 @@ cdef class Polyhedron(_mutable_or_immutable):
             {'bounded': False}
             sage: p.maximize( -x )
             {'bounded': True,
-             'generator': closure_point(0/1),
-             'maximum': False,
+             'sup_n': 0,
              'sup_d': 1,
-             'sup_n': 0}
+             'maximum': False,
+             'generator': closure_point(0/1)}
         """
         cdef PPL_Coefficient sup_n
         cdef PPL_Coefficient sup_d
@@ -2092,10 +2092,10 @@ cdef class Polyhedron(_mutable_or_immutable):
             sage: p = C_Polyhedron(cs)
             sage: p.minimize( x+y )
             {'bounded': True,
-             'generator': point(0/1, 0/1),
-             'inf_d': 1,
              'inf_n': 0,
-             'minimum': True}
+             'inf_d': 1,
+             'minimum': True,
+             'generator': point(0/1, 0/1)}
 
         Unbounded case::
 
@@ -2104,10 +2104,10 @@ cdef class Polyhedron(_mutable_or_immutable):
             sage: p = NNC_Polyhedron(cs)
             sage: p.minimize( +x )
             {'bounded': True,
-             'generator': closure_point(0/1),
-             'inf_d': 1,
              'inf_n': 0,
-             'minimum': False}
+             'inf_d': 1,
+             'minimum': False,
+             'generator': closure_point(0/1)}
             sage: p.minimize( -x )
             {'bounded': False}
         """
diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx
index fbe7be949a..bf9fc0e435 100644
--- a/src/sage/matroids/basis_exchange_matroid.pyx
+++ b/src/sage/matroids/basis_exchange_matroid.pyx
@@ -2297,7 +2297,7 @@ cdef class BasisExchangeMatroid(Matroid):
             sage: M1._is_isomorphic(M2)
             True
             sage: M1._is_isomorphic(M2, certificate=True)
-            (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4})
+            (True, {4: 5, 0: 0, 2: 2, 1: 1, 3: 3, 5: 4})
             sage: M1 = BasisMatroid(matroids.named_matroids.Fano())
             sage: M2 = matroids.named_matroids.NonFano()
             sage: M1._is_isomorphic(M2)
diff --git a/src/sage/matroids/catalog.py b/src/sage/matroids/catalog.py
index a43b3c303c..a35fea6444 100644
--- a/src/sage/matroids/catalog.py
+++ b/src/sage/matroids/catalog.py
@@ -725,7 +725,7 @@ def TernaryDowling3():
         sage: len(list(M.linear_subclasses()))
         72
         sage: M.fundamental_cycle('abc', 'd')
-        {'a': 2, 'b': 1, 'd': 1}
+        {'d': 1, 'a': 2, 'b': 1}
 
     """
     A = Matrix(GF(3), [
diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx
index b46e32faa2..abd7194c03 100644
--- a/src/sage/matroids/circuit_closures_matroid.pyx
+++ b/src/sage/matroids/circuit_closures_matroid.pyx
@@ -393,7 +393,7 @@ cdef class CircuitClosuresMatroid(Matroid):
             sage: M1._is_isomorphic(M2)
             True
             sage: M1._is_isomorphic(M2, certificate=True)
-            (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4})
+            (True, {4: 5, 0: 0, 5: 4, 1: 1, 3: 3, 2: 2})
             sage: M1 = CircuitClosuresMatroid(matroids.named_matroids.Fano())
             sage: M2 = matroids.named_matroids.NonFano()
             sage: M1._is_isomorphic(M2)
diff --git a/src/sage/matroids/graphic_matroid.py b/src/sage/matroids/graphic_matroid.py
index acbec4610c..e3942b2c8f 100644
--- a/src/sage/matroids/graphic_matroid.py
+++ b/src/sage/matroids/graphic_matroid.py
@@ -1058,7 +1058,7 @@ class GraphicMatroid(Matroid):
             sage: M = Matroid(range(5), graphs.DiamondGraph())
             sage: N = Matroid(graph=graphs.DiamondGraph(), regular=True)
             sage: M._is_isomorphic(N, certificate=True)
-            (True, {0: (0, 1), 1: (0, 2), 2: (1, 2), 3: (1, 3), 4: (2, 3)})
+            (True, {4: (2, 3), 2: (1, 2), 0: (0, 1), 1: (0, 2), 3: (1, 3)})
             sage: O = Matroid(graphs.WheelGraph(5))
             sage: M._is_isomorphic(O, certificate=True)
             (False, None)
@@ -1081,7 +1081,7 @@ class GraphicMatroid(Matroid):
             sage: M._is_isomorphic(N, certificate=True)
             (True, {'a': 2, 'b': 4, 'c': 5, 'd': 0, 'e': 1, 'f': 3})
             sage: N._is_isomorphic(M, certificate=True)
-            (True, {0: 'd', 1: 'e', 2: 'a', 3: 'f', 4: 'b', 5: 'c'})
+            (True, {2: 'a', 4: 'b', 5: 'c', 0: 'd', 1: 'e', 3: 'f'})
             sage: O = Matroid(range(6), graphs.CycleGraph(6))
             sage: M._is_isomorphic(O)
             False
@@ -1146,10 +1146,10 @@ class GraphicMatroid(Matroid):
             sage: M2 = Matroid(range(4), graphs.CompleteBipartiteGraph(2,2))
             sage: M1._isomorphism(matroids.named_matroids.BetsyRoss())
             sage: M1._isomorphism(M2)
-            {0: 0, 1: 1, 2: 2, 3: 3}
+            {3: 3, 0: 0, 1: 1, 2: 2}
             sage: M3 = matroids.Uniform(3,4)
             sage: M1._isomorphism(M3)
-            {0: 0, 1: 1, 2: 2, 3: 3}
+            {3: 3, 0: 0, 1: 1, 2: 2}
 
         ::
 
diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
index e72f7748d9..10ed71f53e 100644
--- a/src/sage/matroids/linear_matroid.pyx
+++ b/src/sage/matroids/linear_matroid.pyx
@@ -2254,7 +2254,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
             ....: [1, 0, 1], [0, 1, 1]])
             sage: N._linear_extension_chains(F=set([0, 1]),
             ....:                           fundamentals=set([1, -1, 1/2, 2]))
-            [{0: 1}, {}, {0: 1, 1: 1}, {0: -1, 1: 1}, {1: 1}]
+            [{0: 1}, {}, {1: 1, 0: 1}, {1: 1, 0: -1}, {1: 1}]
         """
 
         if len(F) == 0:
@@ -2341,7 +2341,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
             sage: len(M.linear_extension_chains(F=[0, 1], simple=True))
             0
             sage: M.linear_extension_chains(F=[0, 1, 2], simple=True)
-            [{0: 1, 1: 1, 2: 1}]
+            [{2: 1, 1: 1, 0: 1}]
             sage: N = Matroid(ring=QQ,
             ....:         reduced_matrix=[[-1, -1, 0], [1, 0, -1], [0, 1, 1]])
             sage: L = N.linear_extension_chains(F=[0, 1], simple=True,
@@ -2439,12 +2439,12 @@ cdef class LinearMatroid(BasisExchangeMatroid):
             sage: len(M.linear_coextension_cochains(F=[0, 1], cosimple=True))
             0
             sage: M.linear_coextension_cochains(F=[3, 4, 5], cosimple=True)
-            [{3: 1, 4: 1, 5: 1}]
+            [{5: 1, 4: 1, 3: 1}]
             sage: N = Matroid(ring=QQ,
             ....:         reduced_matrix=[[-1, -1, 0], [1, 0, -1], [0, 1, 1]])
             sage: N.linear_coextension_cochains(F=[0, 1], cosimple=True,
             ....:                           fundamentals=set([1, -1, 1/2, 2]))
-            [{0: 2, 1: 1}, {0: -1, 1: 1}, {0: 1/2, 1: 1}]
+            [{1: 1, 0: 2}, {1: 1, 0: -1}, {1: 1, 0: 1/2}]
         """
         return self.dual().linear_extension_chains(F=F, simple=cosimple, fundamentals=fundamentals)
 
@@ -3342,7 +3342,7 @@ cdef class BinaryMatroid(LinearMatroid):
             sage: M1._is_isomorphic(M2)
             True
             sage: M1._is_isomorphic(M2, certificate=True)
-            (True, {'a': 0, 'b': 1, 'c': 2, 'd': 4, 'e': 3, 'f': 5, 'g': 6})
+            (True, {'f': 5, 'a': 0, 'b': 1, 'd': 4, 'c': 2, 'g': 6, 'e': 3})
 
             sage: M1 = matroids.named_matroids.Fano().delete('a')
             sage: M2 = matroids.Whirl(3)
@@ -3353,7 +3353,7 @@ cdef class BinaryMatroid(LinearMatroid):
             sage: M1._is_isomorphic(matroids.Wheel(3))
             True
             sage: M1._is_isomorphic(matroids.Wheel(3), certificate=True)
-            (True, {'b': 1, 'c': 2, 'd': 4, 'e': 3, 'f': 5, 'g': 0})
+            (True, {'d': 4, 'g': 0, 'e': 3, 'b': 1, 'c': 2, 'f': 5})
 
         """
         if certificate:
@@ -6077,7 +6077,7 @@ cdef class RegularMatroid(LinearMatroid):
             sage: M1._is_isomorphic(M2)
             True
             sage: M1._is_isomorphic(M2, certificate=True)
-            (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4})
+            (True, {4: 5, 0: 0, 3: 3, 1: 1, 2: 2, 5: 4})
 
             sage: M1 = matroids.Wheel(3)
             sage: M2 = matroids.named_matroids.Fano()
@@ -6086,7 +6086,7 @@ cdef class RegularMatroid(LinearMatroid):
             sage: M1._is_isomorphic(M2.delete('a'))
             True
             sage: M1._is_isomorphic(M2.delete('a'), certificate=True)
-            (True, {0: 'g', 1: 'b', 2: 'c', 3: 'e', 4: 'd', 5: 'f'})
+            (True, {4: 'd', 0: 'g', 3: 'e', 1: 'b', 2: 'c', 5: 'f'})
 
         Check that :trac:`17316` was fixed::
 
diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx
index 12e060fc88..a6873e7238 100644
--- a/src/sage/matroids/matroid.pyx
+++ b/src/sage/matroids/matroid.pyx
@@ -3150,7 +3150,7 @@ cdef class Matroid(SageObject):
             sage: M1.is_isomorphic(M2)
             True
             sage: M1.is_isomorphic(M2, certificate=True)
-            (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4})
+            (True, {4: 5, 0: 0, 3: 3, 1: 1, 2: 2, 5: 4})
             sage: G3 = graphs.CompleteGraph(4)
             sage: M1.is_isomorphic(G3)
             Traceback (most recent call last):
@@ -3196,7 +3196,7 @@ cdef class Matroid(SageObject):
             sage: M1._is_isomorphic(M2)
             True
             sage: M1._is_isomorphic(M2, certificate=True)
-            (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4})
+            (True, {4: 5, 0: 0, 3: 3, 1: 1, 2: 2, 5: 4})
 
             sage: M1 = matroids.named_matroids.Fano()
             sage: M2 = matroids.named_matroids.NonFano()
@@ -3986,9 +3986,9 @@ cdef class Matroid(SageObject):
             True
             sage: matroids.named_matroids.NonFano().has_minor(M, certificate=True)
             (True, (frozenset(), frozenset({'g'}),
-                {0: 'b', 1: 'c', 2: 'a', 3: 'd', 4: 'e', 5: 'f'}))
+                {5: 'f', 2: 'a', 3: 'd', 0: 'b', 4: 'e', 1: 'c'}))
             sage: M = matroids.named_matroids.Fano()
-            sage: M.has_minor(M, True)
+            sage: M.has_minor(M, True) # random
             (True,
              (frozenset(),
               frozenset(),
diff --git a/src/sage/matroids/matroids_plot_helpers.py b/src/sage/matroids/matroids_plot_helpers.py
index 1967c76c48..49d1b31d47 100644
--- a/src/sage/matroids/matroids_plot_helpers.py
+++ b/src/sage/matroids/matroids_plot_helpers.py
@@ -121,8 +121,7 @@ def it(M, B1, nB1, lps):
         sage: pts,trilines,nontripts,curvedlines = mph.it(M,
         ....: B1,nB1,M.loops())
         sage: pts
-        {1: (1.0, 0.0), 2: (1.5, 1.0), 3: (0.5, 1.0),
-         4: (0, 0), 5: (1, 2), 6: (2, 0)}
+        {4: (0, 0), 5: (1, 2), 6: (2, 0), 3: (0.5, 1.0), 2: (1.5, 1.0), 1: (1.0, 0.0)}
         sage: trilines
         [[3, 4, 5], [2, 5, 6], [1, 4, 6]]
         sage: nontripts
diff --git a/src/sage/matroids/set_system.pyx b/src/sage/matroids/set_system.pyx
index b4f9a7fd36..4092230d05 100644
--- a/src/sage/matroids/set_system.pyx
+++ b/src/sage/matroids/set_system.pyx
@@ -662,7 +662,7 @@ cdef class SetSystem:
             sage: T = SetSystem(['a', 'b', 'c', 'd'], [['a', 'b'], ['c', 'd'],
             ....:                                      ['a', 'c', 'd']])
             sage: S._isomorphism(T)
-            {1: 'c', 2: 'd', 3: 'b', 4: 'a'}
+            {3: 'b', 4: 'a', 2: 'd', 1: 'c'}
             sage: S = SetSystem([], [])
             sage: S._isomorphism(S)
             {}
@@ -726,7 +726,7 @@ cdef class SetSystem:
             sage: T = SetSystem(['a', 'b', 'c', 'd'], [['a', 'b'], ['c', 'd'],
             ....:                                      ['a', 'c', 'd']])
             sage: S._equivalence(lambda self, other, morph:True, T)
-            {1: 'c', 2: 'd', 3: 'b', 4: 'a'}
+            {3: 'b', 4: 'a', 2: 'd', 1: 'c'}
 
         Check that :trac:`15189` is fixed::
 
diff --git a/src/sage/misc/abstract_method.py b/src/sage/misc/abstract_method.py
index 747f5dcda7..65ef9d9e95 100644
--- a/src/sage/misc/abstract_method.py
+++ b/src/sage/misc/abstract_method.py
@@ -260,8 +260,8 @@ def abstract_methods_of_class(cls):
         ....:     def required2(): pass
 
         sage: sage.misc.abstract_method.abstract_methods_of_class(AbstractClass)
-        {'optional': ['optional1', 'optional2'],
-         'required': ['required1', 'required2']}
+        {'required': ['required1', 'required2'],
+         'optional': ['optional1', 'optional2']}
 
     """
     result = { "required"  : [],
diff --git a/src/sage/modular/arithgroup/arithgroup_perm.py b/src/sage/modular/arithgroup/arithgroup_perm.py
index 6559327295..7a2bec3b04 100644
--- a/src/sage/modular/arithgroup/arithgroup_perm.py
+++ b/src/sage/modular/arithgroup/arithgroup_perm.py
@@ -2388,7 +2388,7 @@ class EvenArithmeticSubgroup_Permutation(ArithmeticSubgroup_Permutation_class):
             sage: G.cusp_widths()
             [1, 1, 4]
             sage: G.cusp_widths(exp=True)
-            {1: 2, 4: 1}
+            {4: 1, 1: 2}
 
             sage: S2 = "(1,2)(3,4)(5,6)"
             sage: S3 = "(1,3,5)(2,4,6)"
diff --git a/src/sage/modular/arithgroup/congroup_gammaH.py b/src/sage/modular/arithgroup/congroup_gammaH.py
index 7c48016348..d47fc3fae3 100644
--- a/src/sage/modular/arithgroup/congroup_gammaH.py
+++ b/src/sage/modular/arithgroup/congroup_gammaH.py
@@ -593,6 +593,7 @@ class GammaH_class(CongruenceSubgroup):
             sage: G = GammaH(240,[7,239])
             sage: G._coset_reduction_data_second_coord()
             {1: [1],
+             240: [1, 7, 49, 103, 137, 191, 233, 239],
              2: [1],
              3: [1],
              4: [1],
@@ -610,8 +611,7 @@ class GammaH_class(CongruenceSubgroup):
              48: [1, 191],
              60: [1, 49, 137, 233],
              80: [1, 7, 49, 103],
-             120: [1, 7, 49, 103, 137, 191, 233, 239],
-             240: [1, 7, 49, 103, 137, 191, 233, 239]}
+             120: [1, 7, 49, 103, 137, 191, 233, 239]}
             sage: G = GammaH(1200,[-1,7]); G
             Congruence Subgroup Gamma_H(1200) with H generated by [7, 1199]
             sage: K = sorted(G._coset_reduction_data_second_coord())
diff --git a/src/sage/modular/dirichlet.py b/src/sage/modular/dirichlet.py
index dd5332c879..6e3e0589ac 100644
--- a/src/sage/modular/dirichlet.py
+++ b/src/sage/modular/dirichlet.py
@@ -2277,7 +2277,7 @@ class DirichletGroup_class(WithEqualityById, Parent):
         TESTS::
 
             sage: DirichletGroup(5)._zeta_dlog
-            {-1: 2, -zeta4: 3, zeta4: 1, 1: 0}
+            {1: 0, zeta4: 1, -1: 2, -zeta4: 3}
         """
         return {z: i for i, z in enumerate(self._zeta_powers)}
 
diff --git a/src/sage/parallel/parallelism.py b/src/sage/parallel/parallelism.py
index ad2dba4fbc..1cd1fa7ba4 100644
--- a/src/sage/parallel/parallelism.py
+++ b/src/sage/parallel/parallelism.py
@@ -297,13 +297,13 @@ class Parallelism(Singleton, SageObject):
 
             sage: Parallelism().reset()
             sage: Parallelism().get_all()
-            {'linbox': 1, 'tensor': 1}
+            {'tensor': 1, 'linbox': 1}
 
         Asking for parallelization on 4 cores::
 
             sage: Parallelism().set(nproc=4)
             sage: Parallelism().get_all()
-            {'linbox': 4, 'tensor': 4}
+            {'tensor': 4, 'linbox': 4}
 
         """
         return self._nproc
diff --git a/src/sage/parallel/use_fork.py b/src/sage/parallel/use_fork.py
index 02b5cdb5be..d42f9881f0 100644
--- a/src/sage/parallel/use_fork.py
+++ b/src/sage/parallel/use_fork.py
@@ -279,7 +279,7 @@ class p_iter_fork(object):
             sage: F._subprocess(operator.add, tmp_dir(), (1, 2))
             sage: sys.stdout = saved_stdout
         """
-        import imp, os, sys
+        import importlib, os, sys
         from sage.misc.persist import save
 
         # Make it so all stdout is sent to a file so it can
@@ -291,7 +291,7 @@ class p_iter_fork(object):
         # pid has changed (forcing a reload of
         # misc).
         import sage.misc.misc
-        imp.reload(sage.misc.misc)
+        importlib.reload(sage.misc.misc)
 
         # The pexpect interfaces (and objects defined in them) are
         # not valid.
diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
index 31131ab220..bc33919835 100644
--- a/src/sage/plot/graphics.py
+++ b/src/sage/plot/graphics.py
@@ -1218,9 +1218,9 @@ class Graphics(WithEqualityById, SageObject):
             sage: kwds = {'f': lambda x: x, 'xmin': 0, 'figsize': [1,1], 'plot_points': (40, 40)}
             sage: G_kwds = Graphics._extract_kwds_for_show(kwds, ignore='xmin')
             sage: kwds # Note how this action modifies the passed dictionary
-            {'f': <function <lambda> at 0x...>,
-             'plot_points': (40, 40),
-             'xmin': 0}
+            {'f': <function <lambda> at 0x...>,
+             'xmin': 0,
+             'plot_points': (40, 40)}
             sage: G_kwds
             {'figsize': [1, 1]}
 
@@ -2151,13 +2151,13 @@ class Graphics(WithEqualityById, SageObject):
 
             sage: l = line([(1e-19,-1), (-1e-19,+1)], aspect_ratio=1.0)
             sage: l.get_minmax_data()
-            {'xmax': 1.00010000000000e-15,
-             'xmin': -9.99900000000000e-16,
-             'ymax': 1.0,
-             'ymin': -1.0}
+            {'xmin': -9.99900000000000e-16,
+             'xmax': 1.00010000000000e-15,
+             'ymin': -1.0,
+             'ymax': 1.0}
             sage: l = line([(0,0), (1,1)], aspect_ratio=1e19)
             sage: l.get_minmax_data()
-            {'xmax': 5000.50000000000, 'xmin': -4999.50000000000, 'ymax': 1.0, 'ymin': 0.0}
+            {'xmin': -4999.50000000000, 'xmax': 5000.50000000000, 'ymin': 0.0, 'ymax': 1.0}
         """
         objects = self._objects
         if objects:
@@ -2210,18 +2210,18 @@ class Graphics(WithEqualityById, SageObject):
 
             sage: l = line([(0,0), (1,1)], aspect_ratio=1.0)
             sage: l._limit_output_aspect_ratio(1, 2, 1e19, 3)
-            {'xmax': -4999.50000000000,
-             'xmin': 5000.50000000000,
-             'ymax': 3,
-             'ymin': 1.00000000000000e19}
+            {'xmin': 5000.50000000000,
+             'xmax': -4999.50000000000,
+             'ymin': 1.00000000000000e19,
+             'ymax': 3}
             sage: l._limit_output_aspect_ratio(1, 2, 3, 1e19)
-            {'xmax': 5000.50000000000,
-             'xmin': -4999.50000000000,
-             'ymax': 1.00000000000000e19,
-             'ymin': 3}
+            {'xmin': -4999.50000000000,
+             'xmax': 5000.50000000000,
+             'ymin': 3,
+             'ymax': 1.00000000000000e19}
             sage: l = line([(0,0), (1,1)], aspect_ratio=1e16)
             sage: l._limit_output_aspect_ratio(0, 1, 2, 3)
-            {'xmax': 5.50000000000000, 'xmin': -4.50000000000000, 'ymax': 3, 'ymin': 2}
+            {'xmin': -4.50000000000000, 'xmax': 5.50000000000000, 'ymin': 2, 'ymax': 3}
         """
         aspect_ratio = self.aspect_ratio()
         if aspect_ratio != 'automatic':
diff --git a/src/sage/plot/histogram.py b/src/sage/plot/histogram.py
index 8dd68e2fee..895689684b 100644
--- a/src/sage/plot/histogram.py
+++ b/src/sage/plot/histogram.py
@@ -75,7 +75,7 @@ class Histogram(GraphicPrimitive):
 
             sage: H = histogram([10,3,5], density=True); h = H[0]
             sage: h.get_minmax_data()  # rel tol 1e-15
-            {'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.4761904761904765, 'ymin': 0}
+            {'xmin': 3.0, 'xmax': 10.0, 'ymin': 0, 'ymax': 0.47619047619047666}
             sage: G = histogram([random() for _ in range(500)]); g = G[0]
             sage: g.get_minmax_data() # random output
             {'xmax': 0.99729312925213209, 'xmin': 0.00013024562219410285, 'ymax': 61, 'ymin': 0}
@@ -94,7 +94,7 @@ class Histogram(GraphicPrimitive):
             sage: h.get_minmax_data()
             doctest:warning ...
             ...VisibleDeprecationWarning: Passing `normed=True` on non-uniform bins has always been broken, and computes neither the probability density function nor the probability mass function. The result is only correct if the bins are uniform, when density=True will produce the same result anyway. The argument will be removed in a future version of numpy.
-            {'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.476190476190..., 'ymin': 0}
+            {'xmin': 3.0, 'xmax': 10.0, 'ymin': 0, 'ymax': 0.4761904761904765}
         """
         import numpy
 
diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py
index 11967fbf96..ccb9c4e0c0 100644
--- a/src/sage/repl/attach.py
+++ b/src/sage/repl/attach.py
@@ -250,13 +250,13 @@ def reset_load_attach_path():
         sage: reset_load_attach_path(); load_attach_path()
         ['.']
         sage: os.environ['SAGE_LOAD_ATTACH_PATH'] = '/veni/vidi:vici:'
-        sage: import imp
-        sage: imp.reload(sage.repl.attach)    # Simulate startup
+        sage: import importlib
+        sage: importlib.reload(sage.repl.attach)    # Simulate startup
         <module 'sage.repl.attach' from '...'>
         sage: load_attach_path()
         ['.', '/veni/vidi', 'vici']
         sage: del os.environ['SAGE_LOAD_ATTACH_PATH']
-        sage: imp.reload(sage.repl.preparse)    # Simulate startup
+        sage: importlib.reload(sage.repl.preparse)    # Simulate startup
         <module 'sage.repl.preparse' from '...'>
         sage: reset_load_attach_path(); load_attach_path()
         ['.']
@@ -596,12 +596,7 @@ def reload_attached_files_if_modified():
         basename = os.path.basename(filename)
         timestr = time.strftime('%T', mtime)
         notice = '### reloading attached file {0} modified at {1} ###'.format(basename, timestr)
-        if ip and ip.pt_cli:
-            with ip.pt_cli.patch_stdout_context(raw=True):
-                print(notice)
-                code = load_wrap(filename, attach=True)
-                ip.run_cell(code)
-        elif ip:
+        if ip:
             print(notice)
             code = load_wrap(filename, attach=True)
             ip.run_cell(code)
diff --git a/src/sage/repl/display/fancy_repr.py b/src/sage/repl/display/fancy_repr.py
index 818498fbae..af33f92126 100644
--- a/src/sage/repl/display/fancy_repr.py
+++ b/src/sage/repl/display/fancy_repr.py
@@ -15,10 +15,12 @@ Representations of objects.
 import types
 
 from IPython.lib.pretty import (
-    _safe_getattr, _baseclass_reprs,
+    _safe_getattr,
     _type_pprinters,
 )
 
+_baseclass_reprs = (object.__repr__,)
+
 from sage.repl.display.util import format_list
 
 
diff --git a/src/sage/repl/display/formatter.py b/src/sage/repl/display/formatter.py
index 5eece441c6..11db26b0db 100644
--- a/src/sage/repl/display/formatter.py
+++ b/src/sage/repl/display/formatter.py
@@ -173,8 +173,8 @@ class SageDisplayFormatter(DisplayFormatter):
             sage: shell.run_cell('ipython_image')
             <IPython.core.display.Image object>
             sage: shell.run_cell('get_ipython().display_formatter.format(ipython_image)')
-            ({u'image/png': ...'\x89PNG...',
-              u'text/plain': u'<IPython.core.display.Image object>'},
+            ({'image/png': ...',
+              'text/plain': '<IPython.core.display.Image object>'},
             {})
 
         Test that IPython images still work even in latex output mode::
diff --git a/src/sage/repl/display/pretty_print.py b/src/sage/repl/display/pretty_print.py
index f3863dea6a..1b270b4e8f 100644
--- a/src/sage/repl/display/pretty_print.py
+++ b/src/sage/repl/display/pretty_print.py
@@ -83,7 +83,7 @@ class SagePrettyPrinter(PrettyPrinter):
             sage: set({1, 2, 3})
             {1, 2, 3}
             sage: dict(zzz=123, aaa=99, xab=10)    # sorted by keys
-            {'aaa': 99, 'xab': 10, 'zzz': 123}
+            {'zzz': 123, 'aaa': 99, 'xab': 10}
     
         These are overridden in IPython in a way that we feel is somewhat
         confusing, and we prefer to print them like plain Python which is
diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
index a2b9988315..15da4c0bab 100644
--- a/src/sage/repl/interface_magic.py
+++ b/src/sage/repl/interface_magic.py
@@ -260,7 +260,7 @@ class InterfaceMagic(object):
             2
             120
             sage: shell.run_cell('%%gap foo\n1+1;\n')
-            File "<string>", line unknown
+            ...File "<string>", line unknown
             SyntaxError: Interface magics have no options, got "foo"
             <BLANKLINE>
             sage: shell.run_cell('%%gap?')
diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
index e843486e26..780cae264d 100644
--- a/src/sage/repl/interpreter.py
+++ b/src/sage/repl/interpreter.py
@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
     dummy line
     ...
     ZeroDivisionError...Traceback (most recent call last)
-    <ipython-input-...> in <module>()
+    <ipython-input-...> in <module>...
     ----> 1 Integer(1)/Integer(0)
     .../sage/rings/integer.pyx in sage.rings.integer.Integer...div... (.../cythonized/sage/rings/integer.c:...)()
     ...
@@ -364,22 +364,19 @@ class SageTestShell(SageShellOverride, TerminalInteractiveShell):
 ###################################################################
 # Transformers used in the SageInputSplitter
 ###################################################################
-from IPython.core.inputtransformer import (CoroutineInputTransformer,
-                                           StatelessInputTransformer,
-                                           _strip_prompts)
+from IPython.core.inputtransformer2 import PromptStripper
 
-@StatelessInputTransformer.wrap
-def SagePreparseTransformer(line):
+def SagePreparseTransformer(lines):
     r"""
     EXAMPLES::
 
         sage: from sage.repl.interpreter import SagePreparseTransformer
-        sage: spt = SagePreparseTransformer()
-        sage: spt.push('1+1r+2.3^2.3r')
-        "Integer(1)+1+RealNumber('2.3')**2.3"
+        sage: spt = SagePreparseTransformer
+        sage: spt(['1+1r+2.3^2.3r'])
+        ["Integer(1)+1+RealNumber('2.3')**2.3"]
         sage: preparser(False)
-        sage: spt.push('2.3^2')
-        '2.3^2'
+        sage: spt(['2.3^2'])
+        ['2.3^2']
 
     TESTS:
 
@@ -400,57 +397,15 @@ def SagePreparseTransformer(line):
         <BLANKLINE>
         sage: shell.quit()
     """
-    if _do_preparse and not line.startswith('%'):
-        return preparse(line)
-    else:
-        return line
-
-@CoroutineInputTransformer.wrap
-def SagePromptTransformer():
-    r"""
-    Strip the sage:/....: prompts of Sage.
-
-    EXAMPLES::
-
-        sage: from sage.repl.interpreter import SagePromptTransformer
-        sage: spt = SagePromptTransformer()
-        sage: spt.push("sage: 2 + 2")
-        '2 + 2'
-        sage: spt.push('')
-        ''
-        sage: spt.push("....: 2+2")
-        '2+2'
-
-    This should strip multiple prompts: see :trac:`16297`::
-
-        sage: spt.push("sage:   sage: 2+2")
-        '2+2'
-        sage: spt.push("   sage: ....: 2+2")
-        '2+2'
-
-    The prompt contains a trailing space. Extra spaces between the
-    last prompt and the remainder should not be stripped::
-
-        sage: spt.push("   sage: ....:    2+2")
-        '   2+2'
-
-    We test that the input transformer is enabled on the Sage command
-    line::
-
-        sage: from sage.repl.interpreter import get_test_shell
-        sage: shell = get_test_shell()
-        sage: shell.run_cell('sage: a = 123')              # single line
-        sage: shell.run_cell('sage: a = [\n... 123]')      # old-style multi-line
-        sage: shell.run_cell('sage: a = [\n....: 123]')    # new-style multi-line
-
-    We test that :trac:`16196` is resolved::
+    lines_out = []
+    for line in lines:
+        if _do_preparse and not line.startswith('%'):
+            lines_out += [preparse(line)]
+        else:
+            lines_out += [line]
+    return lines_out
 
-        sage: shell.run_cell('    sage: 1+1')
-        2
-        sage: shell.quit()
-    """
-    _sage_prompt_re = re.compile(r'^(\s*(:?sage: |\.\.\.\.: ))+')
-    return _strip_prompts(_sage_prompt_re)
+SagePromptTransformer = PromptStripper(prompt_re=re.compile(r'^(\s*(:?sage: |\.\.\.\.: ))+'))
 
 ###################
 # Interface shell #
@@ -612,7 +567,7 @@ def interface_shell_embed(interface):
         sage: shell = interface_shell_embed(gap)
         sage: shell.run_cell('List( [1..10], IsPrime )')
         [ false, true, true, false, true, false, true, false, false, false ]
-        <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None result=[ false, true, true, false, true, false, true, false, false, false ]>
+        <ExecutionResult object at ..., execution_count=None error_before_exec=None error_in_exec=None ...result=[ false, true, true, false, true, false, true, false, false, false ]>
     """
     cfg = sage_ipython_config.copy()
     ipshell = InteractiveShellEmbed(config=cfg,
diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py
index fd27b43fc4..a0a9f80dff 100644
--- a/src/sage/repl/ipython_extension.py
+++ b/src/sage/repl/ipython_extension.py
@@ -511,10 +511,8 @@ class SageCustomizations(object):
         from .interpreter import (SagePreparseTransformer,
                                  SagePromptTransformer)
 
-        for s in (self.shell.input_splitter, self.shell.input_transformer_manager):
-            s.physical_line_transforms.insert(1, SagePromptTransformer())
-            s.python_line_transforms.append(SagePreparseTransformer())
-
+        self.shell.input_transformers_cleanup.insert(1, SagePromptTransformer)
+        self.shell.input_transformers_post.append(SagePreparseTransformer)
 
 class SageJupyterCustomizations(SageCustomizations):
     @staticmethod
diff --git a/src/sage/repl/ipython_tests.py b/src/sage/repl/ipython_tests.py
index d342ba7fac..ab9504337e 100644
--- a/src/sage/repl/ipython_tests.py
+++ b/src/sage/repl/ipython_tests.py
@@ -42,6 +42,7 @@ Next, test the pinfo magic for Cython code::
     Init docstring: ...ee help(type(...)) for...signature...
     File:           .../sage/tests/stl_vector.pyx
     Type:           type
+    ...
 
 Next, test the ``pinfo`` magic for ``R`` interface code, see :trac:`26906`::
 
@@ -67,6 +68,7 @@ calls when you ask for the double-questionmark help, like `foo??` ::
     sage: shell.run_cell(u'from sage.repl.ipython_tests import dummy')
     sage: shell.run_cell(u'%pinfo2 dummy')
     Signature: dummy(argument, optional=None)
+    ...
     Source:
     def dummy(argument, optional=None):
         """
@@ -116,6 +118,7 @@ Next, test the pinfo2 magic for Cython code::
     ...
     File:   .../sage/tests/stl_vector.pyx
     Type:   type
+    ...
 
 Next, test the ``pinfo2`` magic for ``R`` interface code, see :trac:`26906`::
 
diff --git a/src/sage/rings/asymptotic/asymptotic_expansion_generators.py b/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
index 7cddd91066..3f45d0a2f4 100644
--- a/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
+++ b/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
@@ -1464,8 +1464,8 @@ def _sa_coefficients_lambda_(K, beta=0):
          (1, 2): 1/2,
          (2, 2): 1,
          (2, 3): -5/6,
-         (2, 4): 1/8,
          (3, 3): -1,
+         (2, 4): 1/8,
          (3, 4): 13/12,
          (4, 4): 1}
         sage: _sa_coefficients_lambda_(3, beta=1)
@@ -1474,8 +1474,8 @@ def _sa_coefficients_lambda_(K, beta=0):
          (1, 2): 1/2,
          (2, 2): 3,
          (2, 3): -4/3,
-         (2, 4): 1/8,
          (3, 3): -4,
+         (2, 4): 1/8,
          (3, 4): 29/12,
          (4, 4): 5}
     """
diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
index e02192345f..0a93cfb0ed 100644
--- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
+++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
@@ -3781,7 +3781,7 @@ def subs_all(f, sub, simplify=False):
         sage: a = {'foo': x**2 + y**2, 'bar': x - y}
         sage: b = {x: 1 , y: 2}
         sage: subs_all(a, b)
-        {'bar': -1, 'foo': 5}
+        {'foo': 5, 'bar': -1}
     """
     singleton = False
     if not isinstance(f, (list, tuple)):
diff --git a/src/sage/rings/function_field/divisor.py b/src/sage/rings/function_field/divisor.py
index b81d5f5729..515253d351 100644
--- a/src/sage/rings/function_field/divisor.py
+++ b/src/sage/rings/function_field/divisor.py
@@ -394,7 +394,7 @@ class FunctionFieldDivisor(ModuleElement):
             sage: L.<y> = K.extension(Y^3 + x^3*Y + x)
             sage: f = x/(y + 1)
             sage: D = f.divisor()
-            sage: D.dict()
+            sage: D.dict() # random
             {Place (1/x, 1/x^3*y^2 + 1/x): -1,
              Place (1/x, 1/x^3*y^2 + 1/x^2*y + 1): 1,
              Place (x, y): 3,
diff --git a/src/sage/rings/invariants/invariant_theory.py b/src/sage/rings/invariants/invariant_theory.py
index 12a4c130ab..48ca15952a 100644
--- a/src/sage/rings/invariants/invariant_theory.py
+++ b/src/sage/rings/invariants/invariant_theory.py
@@ -2411,10 +2411,10 @@ class BinaryQuintic(AlgebraicForm):
             sage: p = 2*x1^5 + 4*x1^4*x0 + 5*x1^3*x0^2 + 7*x1^2*x0^3 - 11*x1*x0^4 + x0^5
             sage: quintic = invariant_theory.binary_quintic(p, x0, x1)
             sage: quintic.arithmetic_invariants()
-            {'I12': -1156502613073152,
-             'I18': -12712872348048797642752,
-             'I4': -138016,
-             'I8': 14164936192}
+            {'I4': -138016,
+             'I8': 14164936192,
+             'I12': -1156502613073152,
+             'I18': -12712872348048797642752}
 
         We can check that the coefficients of the invariants have no common divisor
         for a general quintic form::
diff --git a/src/sage/rings/multi_power_series_ring_element.py b/src/sage/rings/multi_power_series_ring_element.py
index e5e92420a2..83fa565962 100644
--- a/src/sage/rings/multi_power_series_ring_element.py
+++ b/src/sage/rings/multi_power_series_ring_element.py
@@ -1109,8 +1109,8 @@ class MPowerSeries(PowerSeries):
             sage: s = m + m2
             sage: s.dict()
             {(1, 15, 0, 48): 2/3,
-             (12, 29, 46, 6): 1/2,
              (15, 21, 28, 5): -1,
+             (12, 29, 46, 6): 1/2,
              (39, 5, 23, 30): -1/4}
         """
         out_dict = {}
@@ -1202,9 +1202,9 @@ class MPowerSeries(PowerSeries):
             Multivariate Power Series Ring in s, t over Integer Ring
             sage: f = 1 + t + s + s*t + R.O(3)
             sage: f.coefficients()
-            {s*t: 1, t: 1, s: 1, 1: 1}
+            {1: 1, s: 1, t: 1, s*t: 1}
             sage: (f^2).coefficients()
-            {t^2: 1, s*t: 4, s^2: 1, t: 2, s: 2, 1: 1}
+            {1: 1, s: 2, t: 2, s^2: 1, s*t: 4, t^2: 1}
 
             sage: g = f^2 + f - 2; g
             3*s + 3*t + s^2 + 5*s*t + t^2 + O(s, t)^3
diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
index 7612ed0ddc..38f4d81746 100644
--- a/src/sage/rings/number_field/S_unit_solver.py
+++ b/src/sage/rings/number_field/S_unit_solver.py
@@ -1597,7 +1597,7 @@ def clean_rfv_dict(rfv_dictionary):
         sage: len(rfv_dict)
         4
         sage: rfv_dict
-        {(1, 3): [3, 2], (2, 1): [4, 6], (3, 0): [6, 6], (5, 4): [3, 6]}
+        {(1, 3): [3, 2], (3, 0): [6, 6], (5, 4): [3, 6], (2, 1): [4, 6]}
     """
 
     for a, val in list(rfv_dictionary.items()):
@@ -1761,31 +1761,31 @@ def construct_comp_exp_vec(rfv_to_ev_dict, q):
         sage: from sage.rings.number_field.S_unit_solver import construct_comp_exp_vec
         sage: rfv_to_ev_dict = {(6, 6): [(3, 0)], (5, 6): [(1, 2)], (5, 4): [(5, 3)], (6, 2): [(5, 5)], (2, 5): [(0, 1)], (5, 5): [(3, 4)], (4, 4): [(0, 2)], (6, 3): [(1, 4)], (3, 6): [(5, 4)], (2, 2): [(0, 4)], (3, 5): [(1, 0)], (6, 4): [(1, 1)], (3, 2): [(1, 3)], (2, 6): [(4, 5)], (4, 5): [(4, 3)], (2, 3): [(2, 3)], (4, 2): [(4, 0)], (6, 5): [(5, 2)], (3, 3): [(3, 2)], (5, 3): [(5, 0)], (4, 6): [(2, 1)], (3, 4): [(3, 5)], (4, 3): [(0, 5)], (5, 2): [(3, 1)], (2, 4): [(2, 0)]}
         sage: construct_comp_exp_vec(rfv_to_ev_dict, 7)
-        {(0, 1): [(1, 4)],
+        {(3, 0): [(0, 4)],
+         (1, 2): [(1, 3)],
+         (5, 3): [(3, 5)],
+         (5, 5): [(4, 5)],
+         (0, 1): [(1, 4)],
+         (3, 4): [(3, 2)],
          (0, 2): [(0, 2)],
+         (1, 4): [(0, 1)],
+         (5, 4): [(3, 1)],
          (0, 4): [(3, 0)],
-         (0, 5): [(4, 3)],
          (1, 0): [(5, 0)],
          (1, 1): [(2, 0)],
-         (1, 2): [(1, 3)],
          (1, 3): [(1, 2)],
-         (1, 4): [(0, 1)],
-         (2, 0): [(1, 1)],
-         (2, 1): [(4, 0)],
+         (4, 5): [(5, 5)],
+         (4, 3): [(0, 5)],
          (2, 3): [(5, 2)],
-         (3, 0): [(0, 4)],
-         (3, 1): [(5, 4)],
-         (3, 2): [(3, 4)],
-         (3, 4): [(3, 2)],
-         (3, 5): [(5, 3)],
          (4, 0): [(2, 1)],
-         (4, 3): [(0, 5)],
-         (4, 5): [(5, 5)],
-         (5, 0): [(1, 0)],
          (5, 2): [(2, 3)],
-         (5, 3): [(3, 5)],
-         (5, 4): [(3, 1)],
-         (5, 5): [(4, 5)]}
+         (3, 2): [(3, 4)],
+         (5, 0): [(1, 0)],
+         (2, 1): [(4, 0)],
+         (3, 5): [(5, 3)],
+         (0, 5): [(4, 3)],
+         (3, 1): [(5, 4)],
+         (2, 0): [(1, 1)]}
     """
 
     comp_exp_vec_dict = {}
diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py
index ae3f927842..1f38ab731a 100644
--- a/src/sage/rings/padics/lattice_precision.py
+++ b/src/sage/rings/padics/lattice_precision.py
@@ -1514,7 +1514,7 @@ class DifferentialPrecisionGeneric(SageObject):
 
             sage: prec.history_clear()
             sage: prec.timings()
-            {'add': 0, 'del': 0, 'full reduce': 0, 'mark': 0, 'partial reduce': 0}
+            {'add': 0, 'del': 0, 'mark': 0, 'partial reduce': 0, 'full reduce': 0}
         """
         if self._history is None:
             raise ValueError("History is not tracked")
diff --git a/src/sage/rings/polynomial/groebner_fan.py b/src/sage/rings/polynomial/groebner_fan.py
index 2adafe3309..80ec1d8821 100644
--- a/src/sage/rings/polynomial/groebner_fan.py
+++ b/src/sage/rings/polynomial/groebner_fan.py
@@ -1491,13 +1491,13 @@ class GroebnerFan(SageObject):
             sage: R.<x,y> = PolynomialRing(QQ)
             sage: G = R.ideal([y^3 - x^2, y^2 - 13*x]).groebner_fan()
             sage: G._gfan_stats()
-            {'Dimension of homogeneity space': 0,
-             'Maximal number of polynomials in Groebner basis': 3,
-             'Maximal number of terms in Groebner basis': 6,
+            {'Number of reduced Groebner bases': 3,
+             'Number of variables': 2,
+             'Dimension of homogeneity space': 0,
              'Maximal total degree of a Groebner basis': 4,
              'Minimal total degree of a Groebner basis': 2,
-             'Number of reduced Groebner bases': 3,
-             'Number of variables': 2}
+             'Maximal number of polynomials in Groebner basis': 3,
+             'Maximal number of terms in Groebner basis': 6}
         """
         try:
             return self.__stats
diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx
index c8538ee54a..fa707f47a6 100644
--- a/src/sage/rings/polynomial/laurent_polynomial.pyx
+++ b/src/sage/rings/polynomial/laurent_polynomial.pyx
@@ -2093,7 +2093,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
             sage: L.<w,z> = LaurentPolynomialRing(QQ)
             sage: a = w^2*z^-1 +3
             sage: a.dict()  # indirect doctest
-            {(0, 0): 3, (2, -1): 1}
+            {(2, -1): 1, (0, 0): 3}
         """
         cdef dict D = <dict> self._poly._mpoly_dict_recursive(self._parent.variable_names(),
                                                               self._parent.base_ring())
diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx
index 34762d8de4..9b3fd022f0 100644
--- a/src/sage/rings/polynomial/multi_polynomial.pyx
+++ b/src/sage/rings/polynomial/multi_polynomial.pyx
@@ -504,7 +504,7 @@ cdef class MPolynomial(CommutativeRingElement):
             sage: t,s = R.gens()
             sage: x,y,z = R.base_ring().gens()
             sage: (x+y+2*z*s+3*t)._mpoly_dict_recursive(('z','t','s'))
-            {(0, 0, 0): x + y, (0, 1, 0): 3, (1, 0, 1): 2}
+            {(0, 0, 0): x + y, (1, 0, 1): 2, (0, 1, 0): 3}
 
         TESTS::
 
diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
index 22f29ee596..5f445d2a3b 100644
--- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
@@ -3567,11 +3567,11 @@ class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \
 
             sage: loads(dumps(I)).__getstate__()
             (Monoid of ideals of Multivariate Polynomial Ring in x, y over Finite Field of size 32003,
-             {'_Ideal_generic__gens': (x^2 + x, y),
-              '_Ideal_generic__ring': Multivariate Polynomial Ring in x, y over Finite Field of size 32003,
-              '_cache__groebner_basis': {},
+             {'_Ideal_generic__ring': Multivariate Polynomial Ring in x, y over Finite Field of size 32003,
+              '_Ideal_generic__gens': (x^2 + x, y),
               '_gb_by_ordering': {'degrevlex': [x^2 + x, y]},
               'gens': Pickle of the cached method "gens",
+              '_cache__groebner_basis': {},
               'groebner_basis': Pickle of the cached method "groebner_basis"})
 
         This example checks :trac:`12802`::
diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
index 0311cd71bb..4f26f35011 100644
--- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
+++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
@@ -2990,7 +2990,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
             sage: R.<x,y,z> = QQ[]
             sage: f=2*x*y^3*z^2 + 1/7*x^2 + 2/3
             sage: f.dict()
-            {(0, 0, 0): 2/3, (1, 3, 2): 2, (2, 0, 0): 1/7}
+            {(1, 3, 2): 2, (2, 0, 0): 1/7, (0, 0, 0): 2/3}
         """
         cdef poly *p
         cdef ring *r = self._parent_ring
diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx
index d2dec781fb..449f13dce2 100644
--- a/src/sage/rings/polynomial/plural.pyx
+++ b/src/sage/rings/polynomial/plural.pyx
@@ -2197,7 +2197,7 @@ cdef class NCPolynomial_plural(RingElement):
 
             sage: f = (2*x*y^3*z^2 + (7)*x^2 + (3))
             sage: f.dict()
-            {(0, 0, 0): 3, (1, 2, 3): 2, (2, 0, 0): 7}
+            {(2, 0, 0): 7, (1, 2, 3): 2, (0, 0, 0): 3}
         """
         cdef poly *p
         cdef ring *r
diff --git a/src/sage/rings/polynomial/polydict.pyx b/src/sage/rings/polynomial/polydict.pyx
index 277eaf1844..67ebd2515f 100644
--- a/src/sage/rings/polynomial/polydict.pyx
+++ b/src/sage/rings/polynomial/polydict.pyx
@@ -285,7 +285,7 @@ cdef class PolyDict:
             sage: from sage.rings.polynomial.polydict import PolyDict
             sage: f = PolyDict({(2,3):2, (1,2):3, (2,1):4})
             sage: f.dict()
-            {(1, 2): 3, (2, 1): 4, (2, 3): 2}
+            {(2, 3): 2, (1, 2): 3, (2, 1): 4}
         """
         return self.__repn.copy()
 
diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py
index 81aee6e5de..1957f948ad 100644
--- a/src/sage/rings/polynomial/polynomial_element_generic.py
+++ b/src/sage/rings/polynomial/polynomial_element_generic.py
@@ -340,7 +340,7 @@ class Polynomial_generic_sparse(Polynomial):
             sage: f = w^15 - w*3; f
             w^15 - 3*w
             sage: d = f._dict_unsafe(); d
-            {1: -3, 15: 1}
+            {15: 1, 1: -3}
             sage: d[1] = 10; f
             w^15 + 10*w
         """
diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py
index 5e170e635b..5d5cb2f7ad 100644
--- a/src/sage/rings/polynomial/polynomial_ring.py
+++ b/src/sage/rings/polynomial/polynomial_ring.py
@@ -1205,7 +1205,7 @@ class PolynomialRing_general(sage.algebras.algebra.Algebra):
 
             sage: R.<y,x,a42> = RR[]
             sage: R.gens_dict()
-            {'a42': a42, 'x': x, 'y': y}
+            {'y': y, 'x': x, 'a42': a42}
         """
         gens = self.gens()
         names = self.variable_names()
diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
index 9c6ec027d0..4d3521c3e8 100644
--- a/src/sage/rings/qqbar.py
+++ b/src/sage/rings/qqbar.py
@@ -8053,13 +8053,13 @@ class ANBinaryExpr(ANDescr):
         decrease it before we return::
 
             sage: import sys; sys.getrecursionlimit()
-            1000
+            3000
             sage: s = SymmetricFunctions(QQ).schur()
             sage: a=s([3,2]).expand(8)(flatten([[QQbar.zeta(3)^d for d in range(3)], [QQbar.zeta(5)^d for d in range(5)]]))
             sage: a.exactify(); a # long time
             0
             sage: sys.getrecursionlimit()
-            1000
+            3000
 
         """
         import sys
diff --git a/src/sage/rings/tate_algebra_element.pyx b/src/sage/rings/tate_algebra_element.pyx
index 64ba29c77f..353ba7a950 100644
--- a/src/sage/rings/tate_algebra_element.pyx
+++ b/src/sage/rings/tate_algebra_element.pyx
@@ -2221,7 +2221,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement):
             sage: A.<x,y> = TateAlgebra(R)
             sage: f = 2*x^2 + x
             sage: f.dict()
-            {(1, 0): ...0000000001, (2, 0): ...00000000010}
+            {(2, 0): ...00000000010, (1, 0): ...0000000001}
 
         """
         self._normalize()
diff --git a/src/sage/sandpiles/examples.py b/src/sage/sandpiles/examples.py
index eb38b71170..e08a1f1787 100644
--- a/src/sage/sandpiles/examples.py
+++ b/src/sage/sandpiles/examples.py
@@ -200,7 +200,7 @@ class SandpileExamples(object):
             [1, 1, 1, 1, 1, 2415]
             sage: s = sandpiles.Grid(1,1)
             sage: s.dict()
-            {(0, 0): {(1, 1): 4}, (1, 1): {(0, 0): 4}}
+            {(1, 1): {(0, 0): 4}, (0, 0): {(1, 1): 4}}
         """
         G = graphs.Grid2dGraph(m+2,n+2)
         G.allow_multiple_edges(True)  # to ensure each vertex ends up with degree 4
diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
index cebed8fb19..6e4711a65f 100644
--- a/src/sage/sandpiles/sandpile.py
+++ b/src/sage/sandpiles/sandpile.py
@@ -265,7 +265,7 @@ Working with sandpile divisors::
     sage: D.is_linearly_equivalent(E)
     True
     sage: D.q_reduced()
-    {0: 4, 1: 0, 2: 0, 3: 1}
+    {1: 0, 2: 0, 3: 1, 0: 4}
     sage: S = sandpiles.Complete(4)
     sage: D = SandpileDivisor(S, [0,0,0,5])
     sage: E = D.stabilize(); E
@@ -273,7 +273,7 @@ Working with sandpile divisors::
     sage: D.is_linearly_equivalent(E)
     True
     sage: D.q_reduced()
-    {0: 4, 1: 0, 2: 0, 3: 1}
+    {1: 0, 2: 0, 3: 1, 0: 4}
     sage: D.rank()
     2
     sage: sorted(D.effective_div(), key=str)
@@ -550,7 +550,7 @@ class Sandpile(DiGraph):
             [-1 -2  3  0]
             [ 0  0  0  0]
             sage: s.dict()
-            {0: {1: 1, 2: 1, 3: 1}, 1: {0: 1, 1: 1, 2: 3}, 2: {0: 1, 1: 2, 2: 4}}
+            {0: {1: 1, 2: 1, 3: 1}, 1: {0: 1, 1: 1, 2: 3}, 2: {1: 2, 0: 1, 2: 4}}
 
         Sandpiles can be created from Graphs and DiGraphs. ::
 
@@ -1978,13 +1978,13 @@ class Sandpile(DiGraph):
 
             sage: S = Sandpile({0:[1], 2:[0,1], 1:[2]})
             sage: S.dict()
-            {0: {1: 1}, 1: {2: 1}, 2: {0: 1, 1: 1}}
+            {0: {1: 1}, 2: {0: 1, 1: 1}, 1: {2: 1}}
             sage: T = S.reorder_vertices()
 
         The vertices 1 and 2 have been swapped::
 
             sage: T.dict()
-            {0: {1: 1}, 1: {0: 1, 2: 1}, 2: {0: 1}}
+            {2: {0: 1}, 1: {2: 1, 0: 1}, 0: {1: 1}}
         """
 
         # first order the vertices according to their distance from the sink
@@ -2079,7 +2079,7 @@ class Sandpile(DiGraph):
             sage: s.group_order()
             28
             sage: s.jacobian_representatives()
-            [{0: -5, 1: 3, 2: 2}, {0: -4, 1: 3, 2: 1}]
+            [{1: 3, 2: 2, 0: -5}, {1: 3, 2: 1, 0: -4}]
 
         Let `\tau` be the nonnegative generator of the kernel of the transpose of
         the Laplacian, and let `tau_s` be it sink component, then the sandpile
@@ -2427,7 +2427,8 @@ class Sandpile(DiGraph):
             sage: S = Sandpile({0:{},1:{0: 1, 2: 1, 3: 4},2:{3: 5},3:{1: 1, 2: 1}},0)
             sage: p = S.betti_complexes()
             sage: p[0]
-            [{0: -8, 1: 5, 2: 4, 3: 1}, Simplicial complex with vertex set (1, 2, 3) and facets {(3,), (1, 2)}]
+            [{1: 5, 2: 4, 3: 1, 0: -8},
+             Simplicial complex with vertex set (1, 2, 3) and facets {(3,), (1, 2)}]
             sage: S.resolution()
             'R^1 <-- R^5 <-- R^5 <-- R^1'
             sage: S.betti()
@@ -3005,9 +3006,9 @@ class SandpileConfig(dict):
             sage: c.equivalent_recurrent()
             {1: 1, 2: 1}
             sage: c.__dict__
-            {'_equivalent_recurrent': [{1: 1, 2: 1}, {1: 2, 2: 1}],
-             '_sandpile': Cycle sandpile graph: 3 vertices, sink = 0,
-             '_vertices': [1, 2]}
+            {'_sandpile': Cycle sandpile graph: 3 vertices, sink = 0,
+             '_vertices': [1, 2],
+             '_equivalent_recurrent': [{1: 1, 2: 1}, {1: 2, 2: 1}]}
 
         .. NOTE::
 
@@ -4326,12 +4327,12 @@ class SandpileDivisor(dict):
             sage: D = SandpileDivisor(S,[0,1,1])
             sage: eff = D.effective_div()
             sage: D.__dict__
-            {'_effective_div': [{0: 0, 1: 1, 2: 1}, {0: 2, 1: 0, 2: 0}],
+            {'_sandpile': Cycle sandpile graph: 3 vertices, sink = 0,
+             '_vertices': [0, 1, 2],
+             '_weierstrass_rank_seq': {},
              '_polytope': A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 3 vertices,
              '_polytope_integer_pts': ((0, 0), (1, 1)),
-             '_sandpile': Cycle sandpile graph: 3 vertices, sink = 0,
-             '_vertices': [0, 1, 2],
-             '_weierstrass_rank_seq': {}}
+             '_effective_div': [{0: 0, 1: 1, 2: 1}, {0: 2, 1: 0, 2: 0}]}
             sage: D[0] += 1
             sage: D.__dict__
             {'_sandpile': Cycle sandpile graph: 3 vertices, sink = 0,
@@ -4928,7 +4929,7 @@ class SandpileDivisor(dict):
             sage: s = sandpiles.Complete(4)
             sage: D = SandpileDivisor(s,[2,-3,2,0])
             sage: D.q_reduced()
-            {0: -2, 1: 1, 2: 2, 3: 0}
+            {1: 1, 2: 2, 3: 0, 0: -2}
             sage: D.q_reduced(False)
             [-2, 1, 2, 0]
 
@@ -6360,13 +6361,13 @@ def glue_graphs(g, h, glue_g, glue_h):
         sage: glue_y = {0: 1, 1: 2, 3: 1}
         sage: z = glue_graphs(x,y,glue_x,glue_y); z
         {'sink': {},
-         'x0': {'sink': 1, 'x1': 1, 'x3': 2, 'y1': 2, 'y3': 1},
          'x1': {'x0': 1},
          'x2': {'x0': 1, 'x1': 1},
          'x3': {'x0': 1, 'x1': 1, 'x2': 1},
          'y1': {'sink': 2},
          'y2': {'y1': 2},
-         'y3': {'sink': 1, 'y2': 1}}
+         'y3': {'sink': 1, 'y2': 1},
+         'x0': {'x1': 1, 'x3': 2, 'sink': 1, 'y1': 2, 'y3': 1}}
         sage: S = Sandpile(z,'sink')
         sage: S.h_vector()
         [1, 6, 17, 31, 41, 41, 31, 17, 6, 1]
diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py
index e66c819b59..fb16b84d2f 100644
--- a/src/sage/schemes/elliptic_curves/cm.py
+++ b/src/sage/schemes/elliptic_curves/cm.py
@@ -461,7 +461,67 @@ def discriminants_with_bounded_class_number(hmax, B=None, proof=None):
     Find all class numbers for discriminant up to 50::
 
         sage: sage.schemes.elliptic_curves.cm.discriminants_with_bounded_class_number(hmax=5, B=50)
-        {1: [(-3, 3), (-3, 2), (-3, 1), (-4, 2), (-4, 1), (-7, 2), (-7, 1), (-8, 1), (-11, 1), (-19, 1), (-43, 1)], 2: [(-3, 7), (-3, 5), (-3, 4), (-4, 5), (-4, 4), (-4, 3), (-7, 4), (-8, 3), (-8, 2), (-11, 3), (-15, 2), (-15, 1), (-20, 1), (-24, 1), (-35, 1), (-40, 1)], 3: [(-3, 9), (-3, 6), (-11, 2), (-19, 2), (-23, 2), (-23, 1), (-31, 2), (-31, 1), (-43, 2)], 4: [(-3, 13), (-3, 11), (-3, 8), (-4, 10), (-4, 8), (-4, 7), (-4, 6), (-7, 8), (-7, 6), (-7, 3), (-8, 6), (-8, 4), (-11, 5), (-15, 4), (-19, 5), (-19, 3), (-20, 3), (-20, 2), (-24, 2), (-35, 3), (-39, 2), (-39, 1), (-40, 2), (-43, 3)], 5: [(-47, 2), (-47, 1)]}
+        {5: [(-47, 2), (-47, 1)],
+         1: [(-3, 3),
+          (-3, 2),
+          (-3, 1),
+          (-4, 2),
+          (-4, 1),
+          (-7, 2),
+          (-7, 1),
+          (-8, 1),
+          (-11, 1),
+          (-19, 1),
+          (-43, 1)],
+         3: [(-3, 9),
+          (-3, 6),
+          (-11, 2),
+          (-19, 2),
+          (-23, 2),
+          (-23, 1),
+          (-31, 2),
+          (-31, 1),
+          (-43, 2)],
+         4: [(-3, 13),
+          (-3, 11),
+          (-3, 8),
+          (-4, 10),
+          (-4, 8),
+          (-4, 7),
+          (-4, 6),
+          (-7, 8),
+          (-7, 6),
+          (-7, 3),
+          (-8, 6),
+          (-8, 4),
+          (-11, 5),
+          (-15, 4),
+          (-19, 5),
+          (-19, 3),
+          (-20, 3),
+          (-20, 2),
+          (-24, 2),
+          (-35, 3),
+          (-39, 2),
+          (-39, 1),
+          (-40, 2),
+          (-43, 3)],
+         2: [(-3, 7),
+          (-3, 5),
+          (-3, 4),
+          (-4, 5),
+          (-4, 4),
+          (-4, 3),
+          (-7, 4),
+          (-8, 3),
+          (-8, 2),
+          (-11, 3),
+          (-15, 2),
+          (-15, 1),
+          (-20, 1),
+          (-24, 1),
+          (-35, 1),
+          (-40, 1)]}
     """
     # imports that are needed only for this function
     from sage.structure.proof.proof import get_flag
diff --git a/src/sage/schemes/hyperelliptic_curves/invariants.py b/src/sage/schemes/hyperelliptic_curves/invariants.py
index 4274bd90cc..09a620f745 100644
--- a/src/sage/schemes/hyperelliptic_curves/invariants.py
+++ b/src/sage/schemes/hyperelliptic_curves/invariants.py
@@ -149,42 +149,42 @@ def ubs(f):
         sage: from sage.schemes.hyperelliptic_curves.invariants import ubs
         sage: x = QQ['x'].0
         sage: ubs(x^6 + 1)
-        {'A': 2,
-         'B': 2/3,
-         'C': -2/9,
-         'D': 0,
-         'Delta': -2/3*x^2*h^2,
-         'f': x^6 + h^6,
+        {'f': x^6 + h^6,
          'i': 2*x^2*h^2,
+         'Delta': -2/3*x^2*h^2,
          'y1': 0,
          'y2': 0,
-         'y3': 0}
+         'y3': 0,
+         'A': 2,
+         'B': 2/3,
+         'C': -2/9,
+         'D': 0}
 
         sage: R.<u, v> = QQ[]
         sage: ubs(u^6 + v^6)
-        {'A': 2,
-         'B': 2/3,
-         'C': -2/9,
-         'D': 0,
-         'Delta': -2/3*u^2*v^2,
-         'f': u^6 + v^6,
+        {'f': u^6 + v^6,
          'i': 2*u^2*v^2,
+         'Delta': -2/3*u^2*v^2,
          'y1': 0,
          'y2': 0,
-         'y3': 0}
+         'y3': 0,
+         'A': 2,
+         'B': 2/3,
+         'C': -2/9,
+         'D': 0}
 
         sage: R.<t> = GF(31)[]
         sage: ubs(t^6 + 2*t^5 + t^2 + 3*t + 1)
-        {'A': 0,
-         'B': -12,
-         'C': -15,
-         'D': -15,
-         'Delta': -10*t^4 + 12*t^3*h + 7*t^2*h^2 - 5*t*h^3 + 2*h^4,
-         'f': t^6 + 2*t^5*h + t^2*h^4 + 3*t*h^5 + h^6,
+        {'f': t^6 + 2*t^5*h + t^2*h^4 + 3*t*h^5 + h^6,
          'i': -4*t^4 + 10*t^3*h + 2*t^2*h^2 - 9*t*h^3 - 7*h^4,
+         'Delta': -10*t^4 + 12*t^3*h + 7*t^2*h^2 - 5*t*h^3 + 2*h^4,
          'y1': 4*t^2 - 10*t*h - 13*h^2,
          'y2': 6*t^2 - 4*t*h + 2*h^2,
-         'y3': 4*t^2 - 4*t*h - 9*h^2}
+         'y3': 4*t^2 - 4*t*h - 9*h^2,
+         'A': 0,
+         'B': -12,
+         'C': -15,
+         'D': -15}
     """
     ub = Ueberschiebung
     if f.parent().ngens() == 1:
diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py
index ca8407020f..88f72f17aa 100644
--- a/src/sage/schemes/projective/projective_space.py
+++ b/src/sage/schemes/projective/projective_space.py
@@ -1818,13 +1818,13 @@ class ProjectiveSpace_finite_field(ProjectiveSpace_field):
             sage: P1 = ProjectiveSpace(GF(7),1,'x')
             sage: P1.rational_points_dictionary()
             {(0 : 1): 0,
-             (1 : 0): 7,
              (1 : 1): 1,
              (2 : 1): 2,
              (3 : 1): 3,
              (4 : 1): 4,
              (5 : 1): 5,
-             (6 : 1): 6}
+             (6 : 1): 6,
+             (1 : 0): 7}
         """
         n = self.dimension_relative()
         R = self.base_ring()
diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py
index a1cb20567b..261fad83a3 100644
--- a/src/sage/schemes/riemann_surfaces/riemann_surface.py
+++ b/src/sage/schemes/riemann_surfaces/riemann_surface.py
@@ -1012,17 +1012,17 @@ class RiemannSurface(object):
              (1, 2): (),
              (1, 3): (0,1),
              (1, 6): (),
-             (2, 0): (),
-             (2, 1): (),
              (2, 5): (0,1),
-             (3, 1): (0,1),
              (3, 4): (),
-             (4, 0): (),
-             (4, 3): (),
-             (5, 2): (0,1),
              (5, 7): (),
-             (6, 1): (),
              (6, 7): (),
+             (2, 0): (),
+             (4, 0): (),
+             (2, 1): (),
+             (3, 1): (0,1),
+             (6, 1): (),
+             (5, 2): (0,1),
+             (4, 3): (),
              (7, 5): (),
              (7, 6): ()}
         """
diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
index 9818f2ada9..e87f5d1f74 100644
--- a/src/sage/schemes/toric/morphism.py
+++ b/src/sage/schemes/toric/morphism.py
@@ -647,7 +647,7 @@ class SchemeMorphism_orbit_closure_toric_variety(SchemeMorphism, Morphism):
             sage: P1 = P2_112.orbit_closure(Cone([(1,0)]))
             sage: f = P1.embedding_morphism()
             sage: f._ray_map
-            {N(-1, -2): (-2), N(0, 1): (1), N(1, 0): (0)}
+            {N(1, 0): (0), N(-1, -2): (-2), N(0, 1): (1)}
             sage: f._reverse_ray_map()
             {N(-2): 2, N(1): 1}
         """
@@ -1955,7 +1955,7 @@ class SchemeMorphism_fan_fiber_component_toric_variety(SchemeMorphism):
             N(-1, 2) (11, 1)
             N(1, -3) (9, 2)
             sage: f._ray_index_map
-            {N(-3, 4): 10, N(-1, 2): 11, N(0, 1): 5, N(1, 0): 4, N(2, -6): 9}
+            {N(1, 0): 4, N(0, 1): 5, N(-3, 4): 10, N(2, -6): 9, N(-1, 2): 11}
         """
         try:
             image_ray_index = self._ray_index_map[fiber_ray]
diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py
index 9e913cc1e7..dc01794cd2 100644
--- a/src/sage/schemes/toric/weierstrass.py
+++ b/src/sage/schemes/toric/weierstrass.py
@@ -260,16 +260,16 @@ def Newton_polytope_vars_coeffs(polynomial, variables):
         sage: p = (a30*x^3 + a21*x^2*y + a12*x*y^2 + a03*y^3 + a20*x^2*z +
         ....:      a11*x*y*z + a02*y^2*z + a10*x*z^2 + a01*y*z^2 + a00*z^3)
         sage: p_data = Newton_polytope_vars_coeffs(p, [x,y,z]);  p_data
-        {(0, 0, 3): a00,
-         (0, 1, 2): a01,
-         (0, 2, 1): a02,
-         (0, 3, 0): a03,
-         (1, 0, 2): a10,
-         (1, 1, 1): a11,
+        {(3, 0, 0): a30,
+         (2, 1, 0): a21,
          (1, 2, 0): a12,
+         (0, 3, 0): a03,
          (2, 0, 1): a20,
-         (2, 1, 0): a21,
-         (3, 0, 0): a30}
+         (1, 1, 1): a11,
+         (0, 2, 1): a02,
+         (1, 0, 2): a10,
+         (0, 1, 2): a01,
+         (0, 0, 3): a00}
 
         sage: from sage.geometry.polyhedron.ppl_lattice_polytope import LatticePolytope_PPL
         sage: polytope = LatticePolytope_PPL(list(p_data));  polytope
diff --git a/src/sage/sets/finite_set_map_cy.pyx b/src/sage/sets/finite_set_map_cy.pyx
index cb1f7bff7f..6d606af5aa 100644
--- a/src/sage/sets/finite_set_map_cy.pyx
+++ b/src/sage/sets/finite_set_map_cy.pyx
@@ -311,7 +311,7 @@ cdef class FiniteSetMap_MN(ClonableIntArray):
         EXAMPLES::
 
             sage: FiniteSetMaps(4, 3)([1, 0, 2, 1]).fibers()
-            {0: {1}, 1: {0, 3}, 2: {2}}
+            {1: {0, 3}, 0: {1}, 2: {2}}
             sage: F = FiniteSetMaps(["a", "b", "c"])
             sage: F.from_dict({"a": "b", "b": "a", "c": "b"}).fibers() == {'a': {'b'}, 'b': {'a', 'c'}}
             True
diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
index fe7b8fdec9..5974dd76a0 100644
--- a/src/sage/structure/element.pyx
+++ b/src/sage/structure/element.pyx
@@ -537,8 +537,8 @@ cdef class Element(SageObject):
             sage: i = ideal(x^2 - y^2 + 1)
             sage: i.__getstate__()
             (Monoid of ideals of Multivariate Polynomial Ring in x, y over Rational Field,
-             {'_Ideal_generic__gens': (x^2 - y^2 + 1,),
-              '_Ideal_generic__ring': Multivariate Polynomial Ring in x, y over Rational Field,
+             {'_Ideal_generic__ring': Multivariate Polynomial Ring in x, y over Rational Field,
+              '_Ideal_generic__gens': (x^2 - y^2 + 1,),
               '_gb_by_ordering': {}})
         """
         return (self._parent, self.__dict__)
diff --git a/src/sage/structure/global_options.py b/src/sage/structure/global_options.py
index dcfc14b413..4e06ab69d6 100644
--- a/src/sage/structure/global_options.py
+++ b/src/sage/structure/global_options.py
@@ -1311,9 +1311,9 @@ class GlobalOptions(object):
 
             sage: Partitions.options._reset()
             sage: Partitions.options.__getstate__()
-             {'convention': 'English',
-             'option_class': 'Partitions',
-             'options_module': 'sage.combinat.partition'}
+             {'option_class': 'Partitions',
+              'options_module': 'sage.combinat.partition',
+              'convention': 'English'}
         """
 
         # options classes can be pickled only if they are the options for an
diff --git a/src/sage/structure/indexed_generators.py b/src/sage/structure/indexed_generators.py
index e2322b7ec5..9ad32fc0a0 100644
--- a/src/sage/structure/indexed_generators.py
+++ b/src/sage/structure/indexed_generators.py
@@ -555,7 +555,7 @@ def parse_indices_names(names, index_set, prefix, kwds={}):
         sage: parse_indices_names('x,y,z', None, None, d)
         (('x', 'y', 'z'), {'x', 'y', 'z'}, '')
         sage: d
-        {'bracket': False, 'string_quotes': False}
+        {'string_quotes': False, 'bracket': False}
         sage: d = {}
         sage: parse_indices_names(None, ZZ, None, d)
         (None, Integer Ring, None)
@@ -568,11 +568,11 @@ def parse_indices_names(names, index_set, prefix, kwds={}):
         sage: parse_indices_names(['a','b','c'], ZZ, 'x', d)
         (('a', 'b', 'c'), Integer Ring, 'x')
         sage: d
-        {'bracket': '[', 'string_quotes': True}
+        {'string_quotes': True, 'bracket': '['}
         sage: parse_indices_names('x,y,z', None, 'A', d)
         (('x', 'y', 'z'), {'x', 'y', 'z'}, 'A')
         sage: d
-        {'bracket': '[', 'string_quotes': True}
+        {'string_quotes': True, 'bracket': '['}
     """
     if index_set is None:
         if names is None:
diff --git a/src/sage/structure/proof/all.py b/src/sage/structure/proof/all.py
index 15d8799cb2..af91cd70f4 100644
--- a/src/sage/structure/proof/all.py
+++ b/src/sage/structure/proof/all.py
@@ -219,8 +219,8 @@ def all(t=None):
          'elliptic_curve': True,
          'linear_algebra': True,
          'number_field': True,
-         'other': True,
-         'polynomial': True}
+         'polynomial': True,
+         'other': True}
         sage: proof.number_field(False)
         sage: proof.number_field()
         False
@@ -229,8 +229,8 @@ def all(t=None):
          'elliptic_curve': True,
          'linear_algebra': True,
          'number_field': False,
-         'other': True,
-         'polynomial': True}
+         'polynomial': True,
+         'other': True}
         sage: proof.number_field(True)
         sage: proof.number_field()
         True
diff --git a/src/sage/structure/set_factories.py b/src/sage/structure/set_factories.py
index 804f962d97..ee84b2b91c 100644
--- a/src/sage/structure/set_factories.py
+++ b/src/sage/structure/set_factories.py
@@ -482,8 +482,8 @@ class SetFactoryPolicy(UniqueRepresentation, SageObject):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = XYPairs._default_policy
             sage: pol.self_element_constructor_attributes(XYPair)
-            {'Element': <class 'sage.structure.set_factories_example.XYPair'>,
-             '_parent_for': 'self'}
+            {'_parent_for': 'self',
+             'Element': <class 'sage.structure.set_factories_example.XYPair'>}
         """
         return {'_parent_for': "self", 'Element': Element}
 
@@ -503,8 +503,8 @@ class SetFactoryPolicy(UniqueRepresentation, SageObject):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = XYPairs._default_policy
             sage: pol.facade_element_constructor_attributes(XYPairs())
-            {'_facade_for': AllPairs,
-             '_parent_for': AllPairs,
+            {'_parent_for': AllPairs,
+             '_facade_for': AllPairs,
              'element_class': <class 'sage.structure.set_factories_example.AllPairs_with_category.element_class'>}
         """
         return {'_parent_for': parent,
@@ -533,11 +533,11 @@ class SetFactoryPolicy(UniqueRepresentation, SageObject):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = XYPairs._default_policy
             sage: pol.element_constructor_attributes(())
-            {'Element': <class 'sage.structure.set_factories_example.XYPair'>,
-             '_parent_for': 'self'}
+            {'_parent_for': 'self',
+             'Element': <class 'sage.structure.set_factories_example.XYPair'>}
             sage: pol.element_constructor_attributes((1))
-            {'_facade_for': AllPairs,
-             '_parent_for': AllPairs,
+            {'_parent_for': AllPairs,
+             '_facade_for': AllPairs,
              'element_class': <class 'sage.structure.set_factories_example.AllPairs_with_category.element_class'>}
         """
 
@@ -600,8 +600,8 @@ class SelfParentPolicy(SetFactoryPolicy):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = SelfParentPolicy(XYPairs, XYPair)
             sage: pol.element_constructor_attributes(())
-            {'Element': <class 'sage.structure.set_factories_example.XYPair'>,
-             '_parent_for': 'self'}
+            {'_parent_for': 'self',
+             'Element': <class 'sage.structure.set_factories_example.XYPair'>}
         """
         return self.self_element_constructor_attributes(self._Element)
 
@@ -667,11 +667,11 @@ class TopMostParentPolicy(SetFactoryPolicy):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = TopMostParentPolicy(XYPairs, (), XYPair)
             sage: pol.element_constructor_attributes(())
-            {'Element': <class 'sage.structure.set_factories_example.XYPair'>,
-             '_parent_for': 'self'}
+            {'_parent_for': 'self',
+             'Element': <class 'sage.structure.set_factories_example.XYPair'>}
             sage: pol.element_constructor_attributes((1))
-            {'_facade_for': AllPairs,
-             '_parent_for': AllPairs,
+            {'_parent_for': AllPairs,
+             '_facade_for': AllPairs,
              'element_class': <class 'sage.structure.set_factories_example.AllPairs_with_category.element_class'>}
         """
         factory = self._factory
@@ -768,12 +768,12 @@ class FacadeParentPolicy(SetFactoryPolicy):
             sage: from sage.structure.set_factories_example import XYPairs, XYPair
             sage: pol = FacadeParentPolicy(XYPairs, XYPairs())
             sage: pol.element_constructor_attributes(())
-            {'_facade_for': AllPairs,
-             '_parent_for': AllPairs,
+            {'_parent_for': AllPairs,
+             '_facade_for': AllPairs,
              'element_class': <class 'sage.structure.set_factories_example.AllPairs_with_category.element_class'>}
             sage: pol.element_constructor_attributes((1))
-            {'_facade_for': AllPairs,
-             '_parent_for': AllPairs,
+            {'_parent_for': AllPairs,
+             '_facade_for': AllPairs,
              'element_class': <class 'sage.structure.set_factories_example.AllPairs_with_category.element_class'>}
         """
         return self.facade_element_constructor_attributes(
diff --git a/src/sage/structure/unique_representation.py b/src/sage/structure/unique_representation.py
index 4fc44c8b86..482a288b90 100644
--- a/src/sage/structure/unique_representation.py
+++ b/src/sage/structure/unique_representation.py
@@ -874,7 +874,7 @@ class CachedRepresentation(six.with_metaclass(ClasscallMetaclass)):
         arguments in the instance dictionary upon construction::
 
             sage: x.__dict__
-            {'_reduction': (<class '__main__.MyClass'>, (), {'value': 1}), 'value': 1}
+            {'value': 1, '_reduction': (<class '__main__.MyClass'>, (), {'value': 1})}
 
         It is often easy in a derived subclass to reconstruct the constructor's
         arguments from the instance data structure. When this is the case,
diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
index c76b2f7de7..9464e1422a 100644
--- a/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py
@@ -149,10 +149,10 @@ Sage example in ./graphtheory.tex, line 597::
 Sage example in ./graphtheory.tex, line 608::
 
   sage: C.coloring(hex_colors = True)
-  {'#00ffff': [3, 8, 5],
-     '#7f00ff': [11],
+    {'#ff0000': [0, 2, 7, 10],
      '#7fff00': [1, 4, 6, 9],
-     '#ff0000': [0, 2, 7, 10]}
+     '#00ffff': [3, 8, 5],
+     '#7f00ff': [11]}
   sage: C.show(vertex_colors = C.coloring(hex_colors = True))
 
 Sage example in ./graphtheory.tex, line 644::