Preserve attribute value selection on sort

Maintain the attribute filters when applying a sort
Code cleanup - correctly initialize arrays

The discrete arrays weren't being reset when changing the data set.