Ordering Fixtures

I’m trying to extract_fixtures using the example from the Recipes book
but I want to extract them in order (by id) Does anyone know how to do
that?

data = sorted_array_of_objects_by_id
file.write data.inject({}) { |hash, record|
hash["#{table_name}_#{i.succ!}"] = record
hash
}.to_yaml