function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rohit Vaidya 3Rohit Vaidya 3 

batch execution

i have two records in a batch record-A and Reord -B , but the positioin of record-a is 200th and record b is 5th but i want to read first record-a and then record-b ,how can this be achieved?
SwethaSwetha (Salesforce Developers) 
HI Rohit,
I've come across a similar discussion here: https://salesforce.stackexchange.com/questions/64115/batch-apex-query-order-by-doesnt-sort-all-records according to which the order in which batches of records are processed in Batch Apex is not guaranteed.

It is also mentioned in https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm that "Batches of records tend to execute in the order in which they’re received from the start method. However, the order in which batches of records execute depends on various factors. The order of execution isn’t guaranteed."

Related Idea that you can upvote : https://ideas.salesforce.com/s/idea/a0B8W00000Gdn5pUAB/batch-classes-guarantee-order-of-batches-in-a-batch-class

If this information helps, please mark the answer as best. Thank you