Use array when getting the ordinal value.

Also construct an empty array at the beginning to avoid npe's.