Sorting of materials into groups