Don't have the records sorted to start with.
One trick I learned from UlearnIT here in the forum is that you can suspend the "auto-sort" with a paused script:
Set Allow User Abort [off]
Run this script before you start editing and the records will not resort even when you edit the value of a field specified in the sort order.
Click a button with the Halt Script option or run a script that includes Halt Script as its final step to terminate the above infinite loop in your script.
that works if you do not need to add a record but you can't add with the script on hult