It is similar to radix sort , example you need to sort 123 ,456. 124 so you sort the third position and then second and finally the first so but to sort these positions you need a sorting algorithm which is satble, In the above question there are n positions and n characters to sort so it will be n * nlogn so it will be 2+1*(100) = 102