Sorting items in encoded_array to match the order of fields.