counting sort, bug fixed