Simplifying somewhat, a job sort formula is a sum of weighted values for job attributes. Sometimes, the actual job attributes pass through a function first (e.g, log(), sqrt()), but that doesn't matter here. Without loss of generality, we can normalize the attribute values to range from 0.0 to 1.0. That is, assume the maximum possible value for the first attribute (value1) is max1 and its minimum possible value is min1. Then, we set k1 = (value1 - min1) / (max1 - min1). Do similarly for value2, value3, ... . Then the job sort formula looks like
k1 * w1 + k2 * w2 + k3 * w3
where the w's are the weights for each normalized attribute.
Now, for each attribute, denote the smallest difference in attribute value that matters for sorting as delta1, delta2, ... E.g., for integer priorities, any difference is probably significant. So its delta would be 1. Normalize these deltas the same as you did for values, e1 = delta1 / (max1 - min1)
With this background, we are now ready to try to emulate sort keys with a formula. Starting with the trivial case of one sort key,
the obvious formula is
k1 * 1, or just k1
That is, the weight is 1.
Okay, now let's add the second key. The defining characteristic of keyed sorts is that values for later keys cannot change the order determined by earlier keys. That is, the first key sorts all the items into an ordered list of bins of items that have the same value for the first key. The second key then sorts within those bins. No possible value for the second key can cause an item to move to a different first key bin.
Applying this rule to the case of two keys, the formula becomes:
k1 + k2 * e1
That is, we have to keep the contribution of k2 in the total value to less than the smallest significant change to k1, which is e1.
Continuing with a third key gives
k1 + k2 * e1 + k3 * e1 * e2
So, the weight of each normalized key is the product of the normalized deltas for all previous keys.
This works, provided we can predict a min, max, and delta for each key. For some possible keys, this is easy (e.g., priority). For others, it's a little harder (e.g., job age ranges from 0 to PBS's infinite age (5 years?) and has a delta of one second). But, suppose some site wanted to sort jobs based on the job name. Names can be up to 236 characters long, so our formula has to maintain at least ~1800 bits of precision to distinguish among job names and the weight would require ~500 digits to specify. Floating point keys also require care.
All of this complication goes away with keyed sorts.