Closed zhizhang77 closed 5 years ago
Good find, that code is janky - dict's don't give a guaranteed order for keys.
However, sort() won't fix that line as the alphabetic ordering might not match id ordering. In the example, keys just happen to be sorted both alphabetically and by id.
The best option is to build a reverse dictionary (or list, as it just happens to work).
I'll get this in soon, it might take me a day or two to swing around. :/
Fix verified locally and pushed.
IMO you should sort the list before indexing.
BTW, very helpful tutorial. Thanks for sharing~