Any way to make dictionary maintain order

How did you modify the rest of script to make it do that?