It is excessive to claim that code cannot express the "why". You can almost always express the "why" with code if you really want to, though whether or not that's a good idea is another matter.
For example, you could express the same information that the comment in your example provides in the following manner with self-documenting code.
enum PerformancePrioritization {
FastWorstCase,
FastAverageCase
}
function sort(data: List<TypeOfData>, performancePrioritization: PerformancePrioritization) {
if (performancePrioritization == FastWorstCase) {
heapsort(data);
} else {
quicksort(data);
}
}
...
sort(data, FastWorstCase);