> pi_array_sorted = > { 'general_event_types', ¨ΒΗεξεςαμΕφεξτΤωπ屬 ΗεξεςαμΕφεξτΤωπ岬 ®®έ¬ > 'prices', [Price1, Price2, ..], > 'specific_event_types', [SpecificEventType1, SpecificEventType2, ..], > 'general_event_types', ¨ΒΤεαγθες±Τεαγθες²®®> > 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 = [ ['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