The most aggressive way to tame a feature: throw away the values entirely and keep only the order. A rank transform replaces each value with its position in the sorted data, which makes the result completely immune to outliers and to any monotone distortion of the scale.
Task: write rank_transform(values) returning each value's rank, rounded to 4 decimal places.
1.5; three values tied across positions 1, 2 and 3 all get 2.0.The averaging rule is what keeps the transform fair and self-consistent. Assigning tied values their first or last available position would make the result depend on the order they happened to appear in; averaging is the only choice that treats them identically. It also preserves a useful invariant — the ranks always sum to n(n+1)/2, the same as if nothing had tied.
What you gain is total robustness: every outlier, however extreme, is just "the largest", one step above its neighbour. What you lose is every magnitude — a feature where one value is a thousand times another becomes a feature where it is merely after it. That's the right trade when you only trust the ordering of your measurements, and the wrong one when the distances between them carry real information.