two in-place counting sort implementation