sort arrays
clarified how the creation of masks work