add total count for each chapter and sort by type