find kth smallest in an array