sort cards in backend