Heapsort
Arrange the cards from smallest to largest. Each time, put the largest remaining card at the end of the unfinished row.
Build a tree in which every parent is at least as large as either child. The largest card will then be at the root.
Swap the root with the last available card. Sift the new root down toward the larger child until the heap order is restored.
Building the heap takes O(n) time and the whole sort takes O(n log n). Recursive sifting uses O(log n) stack space.