add countsort and select ith element