VLSI circuit for programmable sorting