Handle non-sorted classes, build RAT

Now builds raster attribute table if can't get raster properties. Also
sorts input classes so can handle out-of-order classes.