I’m trying to figure out how to write a tie-breaker function. The following records are all tied for one reason or another, so to break the tie, we sort each result and then go through each line. The tie is broken at the first point there is a difference.
In the example below on the first pass $result[c] is eliminated, but a and b are still tied. Then on the second pass a is eliminated because it is greater than b. So the result is b, a, c
$result[a] = array(1, 3, 4, 5);
$result[b] = array(1, 2, 3, 7);
$result[c] = array(2, 3, 3, 5);
And to make it even more complicated, I won’t always have the same number of results to compare. It could be anything more than 2.
I really hope this makes sense.
In php, you can actually compare arrays directly using relation operators
php will just loop through the sub arrays, comparing their elements. There’s more detail if you want to read http://php.net/manual/en/language.operators.comparison.php
Anyway, you can take advantage of this and just sort it.
If you need a way to get the n’th place entry, do
and if you need the rank indice of a letter