card distribution and sorting