← All comics

Gary Pinner

#059 2 images

June sorted the top-customer list biggest spender first and put it up in reception. It ranked them like words, so customer of the year had spent nine pounds.

The mistake

The top-customer list sorts spend amounts as strings instead of numbers, so values are compared character by character like text rather than by their numeric value. Under lexicographic ordering, '9' outranks '1000000' because the comparison stops at the first character and '9' is 'greater than' '1', so a nine-pound spender sorts above a million-pound one. This happens whenever a sort key isn't explicitly cast to a numeric type before ordering, and it silently produces plausible-looking but wrong rankings instead of an error.

Share