Ah, thanks for that clarification.
That's a good question. I believe you are correct and the data is only sorted by Object ID.
This would be a nice enhancement to persist a table sort with layer or map.
It does seem that a Portal map will persist the table sort across that map's on-screen lifetime. Not sure if the same behavior translates to a web app
You can enter suggestions for improvements at the GeoNet Ideas site:
GeoNet ArcGIS Ideas
(I didn't see a similar idea in the ArcGIS-Portal section.)
I can think of a work around but it's not very pretty and probably more trouble than just teaching an end user how to sort the table on CODE: You could take your underlying data source, sort it on CODE and then copy to a new Feature Class so that ObjectID would be assigned according to the CODE sort.
But that is then in essence a static table. New records would not be sorted by CODE so you'd have to be constantly rebuilding the data source. Like I said, ugly but doable. If your mxd's data source is a Feature Class in a file geodatabase that you're pulling out of an EGDB, then you could script that transfer to build a new Feature Class sorted appropriately. That might be a viable solution for that scenario.
Good luck!