solve a bug in SortCard()