The corresponding functionality is missing on RecordRef.
On RecordRef we can only set sorting with the RecordRef.CurrentKeyIndex() function, which is bound to the defined Keys on the table.
I have a scenario where I need to find the maximum or minimum value of a given field, but without being able to sort on the specific field I have to loop all records to find out the largest/smallest value and this can of course have a huge negative impact on performance.
I suggest to add a new function on RecordRef with the following signature
RecordRef.SetAscending([FieldNo: Integer [, Ascending: Boolean]])
FieldNo: The number of the field that should be sorted on. If omitted, the sorting for RecordRef would be reset to the primary key in ascending order (similar as RecordRef.Reset(), but it doesn't reset filters)
Ascending: Specifies true if the field should be sorted in ascending order; otherwise false. Default is true.
To sort on more than one field, RecordRef.SetAscending should be called once for each field.
To first sort the RecordRef by field number 1 and then on field number 2:
To first sort the RecordRef by field number 1 descending and then on field number 2 ascending: