Yes, it works.
If you know the palette color with the least maximal deviation from the original color, then you have the best match.
It's simply testing each palette index, and tests the maximal deviation from the original color, if it is less than the previous best match, then this palette index becomes the best match. It's not exactly rocket science :)
If you used the smallest deviation, you would get errors galore. Imagine this:
Palette[0] = 255 255 0
Palette[1] = 254 0 0
Color = 255 0 0
Using the least error would select palette index 0, which is clearly wrong.
If you know the palette color with the least maximal deviation from the original color, then you have the best match.
It's simply testing each palette index, and tests the maximal deviation from the original color, if it is less than the previous best match, then this palette index becomes the best match. It's not exactly rocket science :)
If you used the smallest deviation, you would get errors galore. Imagine this:
Palette[0] = 255 255 0
Palette[1] = 254 0 0
Color = 255 0 0
Using the least error would select palette index 0, which is clearly wrong.