optimize cards sorting