The Arcade function 'Schema()' returns a dictionary, and within that dictionary is a 'fields' element. This 'fields' element is an array of field schema details.
In ArcGIS Pro, this 'fields' array is ordered according to the database schema order.
In ArcGIS Online, the 'fields' array is ordered alphabetically. At least almost alphabetically. The 'OBJECTID' is first, and then another field (which has a coded domain), and then all other fields after that are in alphabetical order.
It is very frustrating that this behaves differently between Pro and Online! Is there any way that I can get the 'Schema()' function to behave the same in both environments?
Ideally, I'd prefer the fields to be returned in database schema order. Firstly, because it's easy to re-sort an array myself if I need to, but more importantly, because this is more likely to be the order that we want to see the fields in. Alphabetical order for fields is rarely useful. And in any case, this is not QUITE alphabetical order!
Arcade code which demonstrates the issue (view the Arcade console in AGOL):
var featureSchema = Schema($feature);
Console(featureSchema.fields);
Esri has two closed bug reports and an enhancement request related to this, as noted in this post