> pi_array_sorted =3D
> { 'general_event_types', =A0[GeneralEventType1, GeneralEventType2, ..],
> =A0 'prices', =A0 =A0 =A0 =A0 =A0 =A0 =A0 [Price1, Price2, ..],
> =A0 'specific_event_types', [SpecificEventType1, SpecificEventType2, ..],
> =A0 'general_event_types', =A0[Teacher1, Teacher2, ..] }
>
> So the keys should be in alphabetical order, but they arent, at least
> not when I iterate over the array using
>

This code above doesn't create an array, it creates an Hash, and Hash
doesn't preserve order.
Do the following:

pi_array_sorted =3D [
  ['general_event_types',  [GeneralEventType1,
GeneralEventType2, ..]],
  ['prices',               [Price1, Price2, ..]],
  ['specific_event_types', [SpecificEventType1,
SpecificEventType2, ..]],
  ['general_event_types',  [Teacher1, Teacher2, ..]]
]

pi_array_sorted.each do |key,value|
  # do stuff here
end

Cheers