Counting in factorize vs. in groupsort function