if I understand you correclty, then:
min_val------->0
any_val------------->scaled_val
max_val------>9
then,
scaled_val = 0 + (9-0)/(max_val-min_val) * (any_val-min_val)
you get you min_val and max_val using max and min functions of whatever language you use, and apply it to your array or dataset.
Hope this helps...